说我有一个行数开始foobar
如何将'foobar'开头的所有行移动到文件末尾?
一个剧本,我想所有的线移动到文档的末尾,同时保持它们的顺序
例如从去:
# There's a Polar Bear
# In our Frigidaire--
foobar['brangelina'] <- 2
# He likes it 'cause it's cold in there.
# With his seat in the meat
foobar['billybob'] <- 1
# And his face in the fish
到
# There's a Polar Bear
# In our Frigidaire--
# He likes it 'cause it's cold in there.
# With his seat in the meat
# And his face in the fish
foobar['brangelina'] <- 2
foobar['billybob'] <- 1
这是据我已经得到了:
grep foobar file.txt > newfile.txt
sed -i 's/foobar//g' foo.txt
cat newfile.txt > foo.txt
提示:输出文件就是所有的行不foobar的开始,接着用foobar的开头的所有行。两个grep命令。 – Amnon
@Amnon谢谢你指出。有道理,但我仍然不知道如何说bash – Abe
@Amnon'-v'得到了它 – Abe