我需要做这样的事情
输入:
text text text text text text text Total number = 2 remaining remaining remaining text text text text text text Total number = 10 remaining remaining text text text text text text Total number = 3 remaining remaining
我想要做的是在
Total number = x之后提取所有内容,
总数= x也应该被删除,简而言之,首先“剩余”部分应该是第一个 每行中的单词,如下所示:
输出:
remaining remaining remaining remaining remaining remaining remaining
答案 0 :(得分:1)
你没有指定语言,但是这里是:
sed的:
s/^.*Total number = [[:digit:]]*[[:space:]]*//
AWK:
{ gsub("^.*Total number = [[:digit:]]*[[:space:]]*", "") ; print }
答案 1 :(得分:1)
使用awk:
awk -F 'Total number = [0-9]+ *' '{print $2}' file
remaining remaining remaining
remaining remaining
remaining remaining
答案 2 :(得分:0)