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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk with no input file or pipe input

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
0
0
PL

is there a way to tell awk $0 is what is on variable?

having this:
$ awk -va="5,10,111" 'BEGIN{print a}'
5,10,111

get output:
111 5 10

so,
awk -F\, -va="5,10,111" ....

 
Hi

Not sure where are you stuck. You only need to assign the desired value to [tt]$0[/tt] and Awk will immediately process it :
Code:
[blue]master #[/blue] awk -F, -va="5,10,111" '[b]BEGIN[/b][teal]{[/teal][navy]$0[/navy] [teal]=[/teal] a[teal];[/teal] [b]print[/b] [i][green]"last field of"[/green][/i][teal],[/teal] NF[teal],[/teal] [i][green]"has value"[/green][/i][teal],[/teal] [navy]$NF[/navy][teal]}[/teal]'
last field of 3 has value 111

Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top