Solved

awk question

Posted on 2006-10-29
4
274 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now