![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pass csh variable to Perl | Raynon | Shell Programming and Scripting | 9 | 10-19-2007 10:46 PM |
| How do I pass a variable to awk? | eja | UNIX for Dummies Questions & Answers | 12 | 04-03-2007 06:46 PM |
| How to pass a variable to Awk ? | Raynon | Shell Programming and Scripting | 24 | 02-26-2007 09:25 AM |
| getting the file name and pass as variable | u263066 | Shell Programming and Scripting | 1 | 09-12-2006 05:38 AM |
| Pass variable to sed? | kristy | Shell Programming and Scripting | 2 | 04-04-2002 04:14 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
actually this is a sample of what i want to do: from the sample code: Code:
grep "keyword" filename | awk '{print $2}' >> outfile
grep "keyword" filename | awk '{print $3}' >> outfile
.
.
.
grep "keyword" filename | awk '{print $32}' >> outfile
i want to shorten it to loop like this: Code:
let x = 2 until test $x > 32 do grep "keyword" filename | awk ...??? let x = x + 1 done so you see i want to pass a variable to awk where the value will also be the variable for print. thanks a lot |
|
|||||
|
Well, I'm assuming "keyword" is the same word in all those lines you have in your first section of code.... and I'm assuming the line it returns is gonna be a long line, and you're trying to print each part of the returned line on it's own line... See if this works for you: Code:
grep "keyword" filename | awk '{ for (i = 1; i <= NF; i++ ) print $i}' >> outfile
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|