• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

awk question

I would like to print every field from the 11th field to the $NF field.  Is there a way to do this?

For example, if there were 14 fields total I would want to print 11th, 12th, 13th, and 14th fields in my awk statement.  But I won't know ahead of time there are 14 total fields, so is there a way to do it using the $NF variable?
0
bryanlloydharris
Asked:
bryanlloydharris
  • 2
  • 2
1 Solution
 
ozoCommented:
awk '{ORS=OFS;for( i=11;i<=NF; i++ ){ print $i }print "\n"}'
0
 
bryanlloydharrisAuthor Commented:
Can you tell me what ORS and what OFS stand for?  (I assume OFS means Output File Seperator?)
0
 
ozoCommented:
      OFS    output field separator (default blank)

       ORS    output record separator (default newline)
0
 
bryanlloydharrisAuthor Commented:
Thanks for all your help!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now