Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk: print colums $1 through to $5

Status
Not open for further replies.

gborrageiro

Technical User
Feb 26, 2008
2
0
0
GB
hi,

Is there a simple way to cat a file a print colums 1 through to 5?
This is how I tediously accomplish this at the moment:
cat file | awk '{print $1$2$3$4$5}'

would be great to use a range of some sort, eg:
cat file | awk '{print $1:$5}'

many thanks
 
Hi

Nope. The best you can do is to use a [tt]for[/tt] loop from 1 to 5 and [tt]print[/tt] the fields one by one.

[tt][ignore][off-topic][/ignore][/tt]
The [tt]cut[/tt] command can handle field ranges.
[tt][ignore][/off-topic][/ignore][/tt]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top