How Do I Print a Column in Linux?
Contents

How do I print the first column in Linux?

The first column of any file can be printed by using $1 variable in awk.

How do I print the last column in Linux?

Use awk with field separator -F set to a space ” “. Use the pattern $1==”A1” and action {print $NF} , this will print the last field in every record where the first field is “A1”.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest