Computing.Net > Forums > Unix > Awk : print certain column ranges

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Awk : print certain column ranges

Reply to Message Icon

Name: daelomin
Date: August 10, 2006 at 09:20:13 Pacific
OS: Linux
CPU/Ram: P4 1gig
Comment:

Hi,

How can one print columns say 4 to end with awk?

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 10, 2006 at 15:08:55 Pacific
Reply:

Assume a default file delimited by whitespace; start at column 4 and print each column to the end. Print a CR at the end of each line:

#!/bin/ksh

awk ' {
for (i=4; i<=NF; i++)
printf("%s ", $i)
printf("\n") # CR at end of line
} ' mydatafile


0

Response Number 2
Name: daelomin
Date: August 21, 2006 at 02:59:09 Pacific
Reply:

Very nice! Thanks!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Awk : print certain column ranges

print columns from files to a file www.computing.net/answers/unix/print-columns-from-files-to-a-file/7615.html

Awk: Repeat first columns, print next ~100 www.computing.net/answers/unix/awk-repeat-first-columns-print-next-100/8398.html

getting awk to print name of file www.computing.net/answers/unix/getting-awk-to-print-name-of-file-/7206.html