I really can't get this one.
File A has this:
1.1.1.1
2.2.2.2
3.3.3.3
etc..
File B will always have the exact same amount of lines and they always will correspond:
oneoneoneone
twotwotwotwo
3ee3ee3ee3ee
I want to append file A to file B so it looks like:
1.1.1.1 oneoneoneone
2.2.2.2 twotwotwotwo
3.3.3.3 3ee3ee3ee3ee
This is what I have but not working like it should:
for z in `cat /tmp/fileB; do sed "s/(.*)/\\1$z/" < /tmp/fileA >> /tmp/c;done
Any suggestions?
If you want to append the lines in fileB to the lines in fileA (as indicated by your desired output), you can simply do:
paste fileA fileB
That uses a tab for the delimeter, so you might prefer
paste -d ' ' fileA fileB
If you want to do it with awk
, you can do:
awk '{ getline b < "fileB"; print $0, b}' fileA
This may be possible with sed
, but it's not advisable. Similar to what you seem to be trying with the loop, you can also do:
while read b; do read -u 4 a; echo $a $b; done < fileb 4< filea
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.