this is the input and i want to print the output as follows: which command or how can we do that?
this is the input
iws 3211296 3178534 0 Jan 19 - 0:00 iws_trs 000 0 1 2
iws 3539162 3526750 0 Jan 19 - 0:00 iws_trs 000 0 1 2 4
iws 3584214 3535080 0 Jan 19 - 0:00 iws_trs 000 0 1 2 3
iws 3928194 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 1 4
iws 3928195 3952828 0 Jan 开发者_运维知识库19 - 0:00 iws_trs 000 0 1 3 5
output: which contains 4 at the end
iws 3539162 3526750 0 Jan 19 - 0:00 iws_trs 000 0 1 2 4
iws 3928194 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 1 4
Which UNIX command can I use or how can we do that?
You can grep for 4$
(the $
means end-of-line).
$ grep '4$' foo.txt
iws 3539162 3526750 0 Jan 19 - 0:00 iws_trs 000 0 1 2 4
iws 3928194 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 1 4
Assuming that the input is coming in from a file, you can use fgrep for this.
Read more here http://nixdoc.net/man-pages/FreeBSD/man1/fgrep.1.html
精彩评论