![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| one question for bash shell script | zx1106 | Shell Programming and Scripting | 9 | 03-10-2008 12:40 AM |
| Bash scripting question re: newlines | retrovertigo | Shell Programming and Scripting | 4 | 07-06-2007 01:44 PM |
| Globbing slash Wildcarding Question | scotbuff | Shell Programming and Scripting | 4 | 02-02-2007 12:10 AM |
| quick newbie bash question | redsand9009 | Shell Programming and Scripting | 4 | 01-25-2007 03:44 AM |
| BASH shell script question | ewarmour | Shell Programming and Scripting | 3 | 05-24-2002 06:10 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk / bash globbing question
I would like to process a list of files matching: GPS*\.xyz with an awk script. I would then like to output the files to GPS*\.xyz.out (e.g. the same file name appended with .out). Something like: Code:
awk '{if(NR==1) {offset=-$1}; $1=$1+offset; print }' GPS*.xyz
this does exactly what I want EXCEPT redirecting the output appropriately. I tried Code:
awk '{ ... print > FILENAME.out}' GPS*.xyz
and
awk '{...}' GPS*.xyz > GPS*.xyz.out
but as expected this did not work. I realize that putting this in: Code:
for f in ls GPS*.xyz loop would work as I need but I would like an elegant solution that I can learn from. Suggestions? Cheers, Brandon Franzke |
|
||||
|
Quote:
Code:
awk 'FNR==1 {offset=-$1;next} {$1+=offset; print >FILENAME".out"}' PS*.xyz
|
|
||||
|
Quote:
Code:
awk 'FNR==1 {offset=$1;close(f);f=FILENAME".out";next}{$1-=offset; print >f}' GPS*.xyz
The next is there becasue I assume you don't want the line with the offset to be printed. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|