How do I get the last word in each line with bash

前端 未结 6 1376
我在风中等你
我在风中等你 2020-12-07 22:35

For example i have a file:

$ cat file

i am the first example.

i am the second line.

i do a question about a file.

and i need:

         


        
6条回答
  •  Happy的楠姐
    2020-12-07 23:13

    You can do something like this in awk:

    awk '{ print $NF }'
    

    Edit: To avoid empty line :

    awk 'NF{ print $NF }'
    

提交回复
热议问题