Problems looping on .csv files
Hi guys,
I'm having problems trying to loop on .csv files, and this problem is new for me, checked elsewhere with no success. I've a oneline script as simple as it could be: Code:
for i in $(cat filename.csv); do echo "$i a"; sleep 1; done _titi@email.com The result, rather than the expected: Code:
email a Code:
aail Any clues? Thanks! Eudald |
you could try
Code:
echo $i a |
Same result kbnuts :(
|
so is the csv actually comma separated or just a list like you put there?
It seems to ignore the underscore and the em in email too from your output. Let me check. |
Certainly looks odd: could be a locale problem.
Was this file created on MSWin instead of Linux? Try running the 'od' cmd http://linux.die.net/man/1/od against the file to check what's really there. |
I think I got it, I just filed the .csv and it's a CRLF line terminated.
I've seen related posts about it here, i.e.: http://www.linuxquestions.org/questi...4/#post3628548 Just to post the solution: Code:
tr -d '\015' < in.csv > out.csv |
I just did it on mine with the contents you listed and got the correct output using your for.
Code:
[root@xcxcxcx ~]# for i in $(cat test.csv); do echo "$i a"; sleep 1; done ---------- Post added 06-25-14 at 05:30 AM ---------- Ah! Nice one! |
All times are GMT -5. The time now is 11:34 PM. |