The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 06:30 AM
Pivot variable record length file and change delimiter thomasr Shell Programming and Scripting 3 10-08-2007 08:40 PM
change some record item happyv Shell Programming and Scripting 7 02-22-2007 05:06 AM
how to use the grep to find detail in a file etravels SUN Solaris 1 03-10-2004 02:03 PM
Getting detail out of a log file... Cameron UNIX for Dummies Questions & Answers 3 08-22-2002 10:36 PM

Closed Thread
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
  #1 (permalink)  
Old 03-11-2007
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
change record detail...in file

hello,

I have a file with the following record:
a.txt

AAjohn10123403
AAmary10298411
AAcat120192a1030
AApeter094857
AAmaybb019485

I have a list called b.txt, if matched the name and it will change to new name (which is after space)
john1 cancel
cat12 cat12
peter peter
mary1 cancel
maybb maybb

can help?
  #2 (permalink)  
Old 03-11-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Try...
Code:
awk 'NR==FNR{a[$1]=$2;next}{for(x in a)sub(x,a[x])};1' b.txt a.txt
  #3 (permalink)  
Old 03-11-2007
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
Quote:
Originally Posted by Ygor
Try...
Code:
awk 'NR==FNR{a[$1]=$2;next}{for(x in a)sub(x,a[x])};1' b.txt a.txt
thx! I will try it later...but can you explain to me above statement? so that I can learn some...
  #4 (permalink)  
Old 03-11-2007
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
Quote:
Originally Posted by Ygor
Try...
Code:
awk 'NR==FNR{a[$1]=$2;next}{for(x in a)sub(x,a[x])};1' b.txt a.txt
not work..


awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
  #5 (permalink)  
Old 03-11-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
If on Solaris, use nawk.
  #6 (permalink)  
Old 03-12-2007
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
Quote:
Originally Posted by Ygor
If on Solaris, use nawk.
Great...it's work!!
Closed Thread

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 02:45 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