The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-03-2005
penfold penfold is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 48
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0