![]() |
|
|
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 |
| Korn shell and awk question | mastachef | Shell Programming and Scripting | 6 | 10-31-2007 07:15 AM |
| korn shell question | mich_elle | Shell Programming and Scripting | 4 | 02-22-2006 09:03 PM |
| Korn Shell Coprocess Performance Question | Mark Puddephat | Shell Programming and Scripting | 8 | 12-14-2005 05:33 PM |
| Korn Shell Loop question | stevefox | Shell Programming and Scripting | 4 | 12-09-2005 01:27 AM |
| Question about Korn Shell | Latha Nair | Shell Programming and Scripting | 13 | 11-05-2003 07:30 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
AWK question in the KORN shell
Hi,
I have two files with the following content: gmrd.txt 235649;03;2563;598 291802;00;2563;598 314634;00;235649;598 235649;03;2563;598 393692;00;2563;598 411805;00;2563;598 411805;00;2563;598 235649;03;2563;598 414037;00;2563;598 575200;00;2563;598 70710;00;2563;598 70710;00;2563;598 235649;03;2563;598 70710;00;2563;598 808932;00;2563;5980 903857;00;2563;5980 979217;00;2563;598 235649;03;2563;598 A0ABVB;00;2563;598 235649;03;2563;598 and val_id.txt 235649;05;2563;598 235649;05;2563;598 564564;05;2563;598 235649;05;2563;598 235649;05;2563;598 212564;05;2563;598 (thesse are small samples of the actual files) What I need to do is to use awk to get the first column of val_id.txt and then search gmrd.txt for any records with instances of the value occuring in the first column of vali_id.txt - if it finds any then it needs to replace the second column of that record by 05 Any help appreciated I get the following error message: ./split.sh[2]: 235649;05;2563;598: syntax error with the following code: for i in $(< val_id.txt );do index[i]="$i" export index awk 'BEGIN { FS = ";"; OFS = ";" } { if ($1 == "${index[i]") $2 = "05" print $0 ; }' gmrd.txt done |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|