I want to use “awk” or sed to print all the lines that start with “comm=” in a file
问题 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 example : comm=rm , comm=ll, comm=ls .... How can i achieve that ? 回答1: 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 回答2: You could use grep also : grep comm= filex this will display all the lines containing comm= . 回答3: Here's an