Jewel
1
Hi Friends,
[pani@vfaul059 ~]$ cat test1.txt
emeka:1438
shelley:1439
dmeyer:1440
kurtarn:1441
abdul:1442
[pani@test.txt ~]$ cat test2.txt
1:a
2:b
3:c
4:d
[pani@test.txt ~]$ cat test3.txt
cat:dog:bat
man:hot:cold
O/P : cat test3.txt
dog:bat:a:1438
hot:cold:b:1439
:c:1440
:d:1441
::1442
Regards,
jewel
joeyg
2
Looks like combining:
fields 2 & 3 from test3 with
field 2 from test2 with
field 2 from test2
Is that correct?
Jewel
3
O/P:
--------------------------------------
fisrst column of 3rd file:3rd column of 3rd file:2nd colun of 2nd file:2nd column of 1st file
try:
paste test3.txt test2.txt test1.txt |
awk '{for(i=1; i<=NF; i++) sub(/[^:]*:/,x,$i)}1' FS='\t' OFS=:
dog:bat:a:1438
hot:cold:b:1439
:c:1440
:d:1441
::1442
1 Like
Jewel
5
Really your are champ
---------- Post updated 03-18-15 at 03:35 AM ---------- Previous update was 03-17-15 at 01:16 PM ----------
[pani@testenv ~]# paste test1.txt test2.txt test3.txt | awk '{for(i=1; i<=NF; i++) sub(/[^:]*:/,x,$i)}1' FS='\t' OFS=:
1438:a:dog:bat
1439:b:hot:cold
1440:c:
1441:d:
1442::
Small correction in O/P :
1438:a:dog:bat
1439:b:hot:cold
1440:c::
1441:d::
1442:::
---------- Post updated at 05:28 AM ---------- Previous update was at 03:35 AM ----------
Hi Friends,
Need your help to fix.
[pani@testenv ~]# paste test1.txt test2.txt test3.txt | awk '{for(i=1; i<=NF; i++) sub(/[^:]*:/,x,$i)}1' FS='\t' OFS=:
1438:a:dog:bat
1439:b:hot:cold
1440:c:
1441:d:
1442::
Small correction in O/P :
1438:a:dog:bat
1439:b:hot:cold
1440:c::
1441:d::
1442:::
RudiC
6
For exactly this special case, try
paste file1 file2 file3 | awk '!$NF{$NF="::"} {for(i=1; i<=5; i++) sub(/[^:]*:/,x,$i)}1' FS='\t' OFS=:
1438:a:dog:bat
1439:b:hot:cold
1440:c::
1441:d::
1442:::