Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

awk question

Posted on 2006-10-29
4
Medium Priority
?
291 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 85

Accepted Solution

by:
ozo earned 2000 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 85

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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month9 days, 2 hours left to enroll

876 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