命令“打印所有以...开头的行”。 [英] Command "Print All Lines Starting With"
本文介绍了命令“打印所有以...开头的行”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个perl命令,其中打印以字符串开头的行。例如,如果我想打印所有以 1234开头的行,该命令将是什么样?塞德啊Grep?
I am looking for a perl command where lines starting with a string are printed. For example, if I wanted to print all lines starting with "1234", what would that command look like? Sed? Awk? Grep?
推荐答案
perl -ne 'print if /^1234/'
或
sed -ne '/^1234/p'
或
awk '/^1234/'
或
grep '^1234'
或
ruby -ne 'print if /^1234/'
甚至
python -c 'import fileinput;print "\n".join([l for l in fileinput.input() if l.startswith("1234")])'
这篇关于命令“打印所有以...开头的行”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文