I want to use \"awk\" or \"sed\" to print all the lines that start with comm=
from the file filex
, Note that each line contains \"comm=somthing\"
For lines that start with comm=
sed -n '/^comm=/p' filex
awk '/^comm=/' filex
If comm=
is anywhere in the line then
sed -n '/comm=/p' filex
awk '/comm=/' filex
Here's an approach using grep:
grep -o '\<comm=[[:alnum:]]*\>'
This treats a word as consisting of alphanumeric characters; extend the character class as needed.
You could use grep also :
grep comm= filex
this will display all the lines containing comm=
.
If grep
is ok to use, you could give a try to:
grep -E "^comm=" file