【发布时间】:2012-06-19 16:31:54
【问题描述】:
我有一个命令行程序,可以打印出如下报告:
I found 0 problems on your database,
0 problems were found on your database
等等。
我想编写一个仅将数字导出到变量的 linux shell 脚本。我找不到这样做的正确方法。我怀疑我没有正确使用grep(或者有更好的命令);
即
I found 43 problems on your database,
43 problems were found on your database
$VAR=43
请指教
【问题讨论】:
-
你的输出是 2 行还是很多行?
-
学习使用和组合
awk和grep,也许还有一些脚本语言,如python、ocaml、ruby或perl。
标签: linux shell scripting sed awk