How to print all the columns after a particular number using awk?

后端 未结 11 694
一生所求
一生所求 2020-12-22 20:23

On shell, I pipe to awk when I need a particular column.

This prints column 9, for example:

... | awk \'{print $9}\'

How can I tell

11条回答
  •  天命终不由人
    2020-12-22 21:15

    Using cut instead of awk and overcoming issues with figuring out which column to start at by using the -c character cut command.

    Here I am saying, give me all but the first 49 characters of the output.

     ls -l /some/path/*/* | cut -c 50-
    

    The /*/*/ at the end of the ls command is saying show me what is in subdirectories too.

    You can also pull out certain ranges of characters ala (from the cut man page). E.g., show the names and login times of the currently logged in users:

           who | cut -c 1-16,26-38
    

提交回复
热议问题