|
Re: Replacing a pattern in one file by reading a string from anotherfile: msg#00022editors.sed.user
On Thu, 08 Dec 2005 14:42:31 +0800, <kaushik.m@xxxxxxx> wrote: > > Hi , > I found out another way(though quite lame , i admit) to do this > same thing :- > > paste 2 3 | sed 's/:/ /g' | awk '{print $3,":",$2}' > (Here we can always replace the awk part by the sed equivalent) > > File 2 contains : > > username:SAPextract > password:$$$$$ > Monthtoextract: October > > and File 3 contains : > > RunasUser: $username > RunasPsswd: $password > RunMonth: $Monthtoextract > Since you use awk and since you may want to get on more solution, I will give my gawk solution: -------f.awk ARGIND-2{ # if the 1st argument ("f2" in this case) a["$"$1]=$2 # put 2nd field into an array with the index next} # set to the value of 1st field. $2 in a{ # if the variable has been defined in "f2" sub("\\"$2,a[$2])} #then substitue 1 # print the content of "f3". -------end of f.awk ------------------ $ awk -F": *" -f f.awk f2 f3 RunasUser: SAPextract RunasPsswd: $$$$$ RunMonth: October ------------------ -- hq00e ------------------------ Yahoo! Groups Sponsor --------------------~--> Fair play? Video games influencing politics. Click and talk back! http://us.click.yahoo.com/u8TY5A/tzNLAA/yQLSAA/dkFolB/TM --------------------------------------------------------------------~-> -- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/sed-users/ <*> To unsubscribe from this group, send an email to: sed-users-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Stingily extracting a block of lines: 00022, Angus Leeming |
|---|---|
| Next by Date: | produce standard output from input file: 00022, shamrul ismawi |
| Previous by Thread: | Re: Replacing a pattern in one file by reading a string from anotherfilei: 00022, kaushik . m |
| Next by Thread: | produce standard output from input file: 00022, shamrul ismawi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |