I have a file that is returning the following text:
10.10.10.160:1111
10.10.10.170:2222
10.10.10.180:3333
grep -m 1 -o '.*' filename | cut -d ':' -f
I tried the above and I can get just 1 single line of output.
10.10.10.160
However when I tried with
grep -m 2 -o '.*' filename | cut -d ':' -f
10.10.10.160
10.10.10.170
I get the above.
If I want to get just the 2nd line
10.10.10.170
Is there any way to do it?
Best Answer
Results:
tail -n 1
prints only the last line of the results ofgrep -m 2 -o '.*' filename | cut -d ':' -f 1
The original text file is named filename.