You are not logged in.
Hello, normally I use this:
awk 'NR==FNR{a[FNR]=$0;next} {print a[FNR],$0}' file1 file2 > file3
so if i joined a file containing:
aaa
bbb
ccc
and another file containing:
ddd
eee
fff
I get:
aaa ddd
bbb eee
ccc fff
But right now I need to get:
aaaddd
bbbeee
cccfff
Pray help me, I have been writing my crappy script for about 10 hours now and it still doesn't do what i want...
Last edited by darkbeanies (2011-08-23 17:22:38)
Offline
paste --delimiters="" a.txt b.txt
or you can remove the comma from your awk print statement
Last edited by carlocci (2011-08-23 17:39:57)
Offline
Looking good! Many many thanks!
I really should learn awk i think...
Last edited by darkbeanies (2011-08-23 17:40:59)
Offline
If you wanted to do it with awk, your solution works, just get rid of the comma in the print statement:
awk 'NR==FNR{a[FNR]=$0;next} {print a[FNR] $0}' file1 file2
aaabbb
aaabbb
aaabbb
bah... carlocci beat me to it.
Last edited by falconindy (2011-08-23 17:44:07)
Offline
bah... carlocci beat me to it.
I can give you some more jolly puzzles later if you'd like...
Offline
Another meaningless way:
join <(nl file_a) <(nl file_b) | mawk '{print $2$3}'
prints
aaaddd
bbbeee
cccfff
or
join <(nl file_a) <(nl file_b) | mawk '{print $2,$3}'
prints
aaa ddd
bbb eee
ccc fff
Using "nl" to make each line common so as to join them.
In solving a problem of this sort, the grand thing is to be able to reason backward. That is a very useful accomplishment, and a very easy one, but people do not practice it much. In the everyday affairs of life it is more useful to reason forward, and so the other comes to be neglected. There are fifty who can reason synthetically for one who can reason analytically. --Sherlock Holmes
Offline
Sage advice from Holmes as usual.
Offline