Wednesday, August 03, 2005

Copying scripts (*.sh) edited on Windows or cygwin to Linux/Unix machine

If you are copying the scripts (*.sh) edited on Windows or cygwin to Linux/Unix machine (cygwin is fine), please ensure all trailing carriage returns are stipped, else scripts will NOT be interpreted properly:

#!/bin/bash
files=`ls *.sh`
for file in $files
do
echo "processing file -$file "
sed s/^M$//g $file >/tmp/tempfile
mv /tmp/tempfile $file
done

0 Comments:

Post a Comment

<< Home