Paste command issue

Problem with Paste command :slight_smile:
Hi All,

i need small suggestion in my below script...

i have output in .txt format like below

file1.txt
01111111
02222222
03333333

file2.txt
230125
000012
000002

now i want to merge both the file in xls or csv formate

now i am using the below command to merge the files..

paste -d ',' file1.txt file2.txt

but some time i get output like below..in unix screen..

,230125
,000012
,000002

if i open the file with xl..then i could see the output like below

01111111
230125
02222222
000012
03333333
000002

can anyone suggest me to correct it..

would be great ...

Thanks
Sha

Windows file have <cr><lf> with line end.
Linux file only have <lf> with line end.

So paste command can recognize <lf> between the line and the other line.

Therfore you need to exchange line end char <cr><lf> to <lf> with below command before you use paste command.

sed -e 's/\r$//' -i file1.txt
sed -e 's/\r$//' -i file2.txt

Thanks a lot....

above command working fine,,..

Thanks
Sha..:wink: