|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
hey guys,
i hav got two files as follows file1.txt bss:1 bss:2 bss:3 bss:4 bss:5 file2.txt db1 db2 db3 db4 db5 i m reading the first file using a for loop so when i read the first line in file1.txt (ie bss:1) i need to get the corresponding one in file2 (ie. db1) like wise till db5 when i reads bss:5 how can i implemnt it usig an awk with in a for loop? thanks in advance |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
varkey@changingideas.com wrote:
> hey guys, > > i hav got two files as follows > > file1.txt > > bss:1 > bss:2 > bss:3 > bss:4 > bss:5 > > > file2.txt > db1 > db2 > db3 > db4 > db5 > > > i m reading the first file using a for loop Using something like for line in `cat file1.txt` I suppose. > so when i read the first line in file1.txt (ie bss:1) i need to get > the corresponding one in file2 (ie. db1) > > like wise till db5 when i reads bss:5 > > how can i implemnt it usig an awk with in a for loop? You can use awk without any loop at all (assuming your input lines have no spaces in them): $ paste file1.txt file2.txt | awk '{print $1,$2}' or, if you absolutely want to use a loop $ paste file1.txt file2.txt | while read line1 line2; do .... -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 3/15/2008 2:37 PM, varkey@changingideas.com wrote: > hey guys, > > i hav got two files as follows > > file1.txt > > bss:1 > bss:2 > bss:3 > bss:4 > bss:5 > > > file2.txt > db1 > db2 > db3 > db4 > db5 > > > i m reading the first file using a for loop > > so when i read the first line in file1.txt (ie bss:1) i need to get > the corresponding one in file2 (ie. db1) > > like wise till db5 when i reads bss:5 > > how can i implemnt it usig an awk with in a for loop? > > thanks in advance > It sounds like all you really want is: paste file1 file2 If not post a rationale and some expected output for . Ed. |
|
![]() |
| Outils de la discussion | |
|
|