![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| sed string manipulation | speedieB | Shell Programming and Scripting | 4 | 11-23-2008 08:27 PM |
| string manipulation | james6 | UNIX for Dummies Questions & Answers | 5 | 06-03-2008 10:05 AM |
| String Manipulation Help | shadow0001 | Shell Programming and Scripting | 4 | 03-09-2008 04:35 PM |
| string manipulation | Cactus Jack | Shell Programming and Scripting | 9 | 02-14-2008 01:14 PM |
| string manipulation | hai1973 | Shell Programming and Scripting | 13 | 08-20-2007 11:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
awk string manipulation
Here is my awk code in a shell script:
localRecDir=/somedirectory/ # awk -v LRD="$localRecDir" '{out = sprintf ("%s0000000%s"),LRD,substr($3,4) ; print > out; close(out)}' *.log Here is the contents of my *.log file I am trying to parse with my script: 000007 0110 07-0001583 000007 0110 07-0001584 000007 0110 07-0001585 I am expecting my script to: 1) get the 3rd field of my log file. 2) strip off the "07-" from the 3rd field 3) use sprintf to format a "pathname" to the "out" variable. Essentially, I am trying to create 3 files: /somedirectory/00000000001583 /somedirectory/00000000001584 /somedirectory/00000000001585 But I get this error: awk: Syntax error at line 1 of program << {out = sprintf ("%s0 ... >> context is {out = sprintf >>> ("%s0000000%s"), <<< awk: illegal statement at line 1 of program << {out = sprintf ("%s0 ... >> Can someone please point out what I am doing incorrectly. TIA zoo591 |
|
||||
|
Quote:
The script now works as intended. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|