我想使用"awk"或sed来打印文件中以"comm ="开头的所有行

wae*_*ael 11 linux shell scripting awk sed

我想使用"awk"或"sed"打印comm=从文件开头的所有行filex,注意每行包含"comm = somthing"

for example : comm=rm , comm=ll, comm=ls  ....
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现这一目标?

jay*_*ngh 25

对于以.开头的行 comm=

sed -n '/^comm=/p' filex

awk '/^comm=/' filex
Run Code Online (Sandbox Code Playgroud)

如果在线comm=的任何地方那么

sed -n '/comm=/p' filex

awk '/comm=/' filex
Run Code Online (Sandbox Code Playgroud)


Céd*_*ien 6

你也可以使用grep:

grep comm= filex
Run Code Online (Sandbox Code Playgroud)

这将显示包含的所有行comm=.