If I want to get the "shallow years of love sleeves" to "fall into the Midgard injury to me" between the content.
1. First get the line number where they are located:
-N option to display line numbers
But sometimes grep shows "match to Binary (standard input)", indicating that the search string in a binary file matches to, do not want to match the binary file, with Grep-a.
[e-mail protected]:~# grep-an ' Shallow years full of love sleeves ' abc |awk-f: ' {print $} '3root@ubuntu: ~# c5> Grep-an ' fall into the midgard injury to me ' ABC |cut-d:-F16
awk sets the delimiter to ":" and then prints the contents of a 1th chunk
You can also use cut to do,-D to set the delimiter,-f1 take the 1th chunk of the content
2. Use sed-n ' start line, end line P ' filename
[Email protected]:~# sed-n ' 3,6p ' abc man: Shallow Years of love sleeve piece Fangfei into the water female: Cool Providence billow a suit into the midgard injury to me
If you are viewing a row:
[Email protected]:~# sed-n ' 3p ' abc man: Shallow years full of love sleeves
Linux Get log Specifies the number of rows in the range of content