All,
I have 2 files A and B with some data. Now i want to concat data from both the files in to 3rd file.Please help me with a single command line.
A--123456789
B--jlsjdfkajsjas
output file C should be 123456789,jlsjdfkajsjas
All,
I have 2 files A and B with some data. Now i want to concat data from both the files in to 3rd file.Please help me with a single command line.
A--123456789
B--jlsjdfkajsjas
output file C should be 123456789,jlsjdfkajsjas
Now THIS is a laconic specification. Try paste
.
Hello kiranparsha,
Could you please try following. Let's say following are the Input_files.
cat Input_file1
123456789
1234567891212
1234567
cat Input_file2
jlsjdfkajsjas
jlsjdfkjlsjdfkajsjaqqwewq
paste -d, Input_file1 Input_file2
Output will be as follows.
123456789,jlsjdfkajsjas
1234567891212,jlsjdfkjlsjdfkajsjaqqwewq
1234567,
So as above you could see if number of lines are not same in Input_file1 and Input_file2 then it should show comma either in starting of the output(When Input_file2 has more lines than Input_file1) or at last of the output(When Input_file1 has more lines than Input_file2), so if you don't want this situation then try following.
paste -d, file1 file2 | sed 's/,$//g;s/^,//g'
Output will be as follows then.
123456789,jlsjdfkajsjas
1234567891212,jlsjdfkjlsjdfkajsjaqqwewq
1234567
Thanks,
R. Singh