Solved

awk question

Posted on 2006-10-29
4
281 Views
Last Modified: 2010-04-20
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
Comment
Question by:bryanlloydharris
  • 2
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 17831506
awk '{ORS=OFS;for( i=11;i<=NF; i++ ){ print $i }print "\n"}'
0
 
LVL 3

Author Comment

by:bryanlloydharris
ID: 17835933
Can you tell me what ORS and what OFS stand for?  (I assume OFS means Output File Seperator?)
0
 
LVL 84

Expert Comment

by:ozo
ID: 17836037
      OFS    output field separator (default blank)

       ORS    output record separator (default newline)
0
 
LVL 3

Author Comment

by:bryanlloydharris
ID: 17838011
Thanks for all your help!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question