1752646 Members
6009 Online
108788 Solutions
New Discussion юеВ

Re: perl + csv

 
Piotr Kirklewski
Super Advisor

Re: perl + csv

sed -i s/'^M'/""/ test.csv

Sorted :)
Jesus is the King
Piotr Kirklewski
Super Advisor

Re: perl + csv

If i put this line in the script:

/bin/sed -i s/'^M'/""/ /home/peter/test/"0041"$TODAY".csv"

It gets interpreted as:

/bin/sed -i 's/^M//' /home/peter/test/004120110530.csv

And it doesn't remove the ^M from the file.

How to fix this ?

Jesus is the King
James R. Ferguson
Acclaimed Contributor

Re: perl + csv

Hi (again):

> Maybe paste is not that bad but it inserts ^M after the last column of the first file and before the first column of the second file:

Then your file contained the carriage return in the first place. 'paste' uses a tab character as its default unless you override it with '-d .

Since you asked about Perl, you could remove the nasty carriage-returns with:

# perl -pi -e 's{\r$}{}' file

...which will do an in-place update of 'file' ridding it of the pesky carriage-returns.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: perl + csv

>It gets interpreted as:

Are you using control-V control-M to insert the CR into the string?
sed -i -e 's/^V^M//' 004120110530.csv

Otherwise you can use echo:
sed -i -e 's/$(echo "\r\c")//' 004120110530.csv