How Do I Print a Second Column in Unix?
Contents

How do I print a 2nd column in Unix?

We can also print multiple columns and insert our custom string in between columns. For example, to print the permission and filename of each file in the current directory, use the following set of commands: $ ls -l | awk ‘{ print $1 ” : ” $8 }’ -rw-r–r– : delimited_data.

How do I print 2nd and 3rd column in Unix?

7 Answers. then you can use cut -d’ ‘ -f2- to print, from a space-separated values file, the contents from the second column to the last one. The part NF>=3 is to safely validate you are printing the last 3 fields on lines that is guaranteed to have at least 3 fields.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest