1) ftp the files using ascii mode
or
2) use dos2unix in Unix. (Most O.S should have this) if you don't
Then
3) use any of the below for one time .
cat filename |perl -pe 's/\015\012/\n/g' > filename.without.ctrl.m
or
This will do an inline edit of the file, if you wish to do every file in the directory
perl -p -i -e 's/^M//g' *
or
sed 's/^M//g' ${INPUT_FILE} > tmp.txt
mv tmp.txt ${INPUT_FILE}
ortr -d "\15" < ${INPUT_FILE} > tmp.txt;
mv tmp.txt ${INPUT_FILE}or)
For multiple files.
#!/bin/ksh
for f in `ls *.CSV` ###( change this .CSV to whatever file extensions you have)
do
mv $f ${f}~ && tr -d '\015\032' <${f}~ >$f
rm ${f}~
done
No comments:
Post a Comment