Your script is working manually one by one at the command prompt.
But I am trying to do automatic the script is below which is not working.
For ^M character --> I am pressing < crtl v and Ctrl M> in the script.
for file in `ls /home/applmgr/test/`
do
CHECK=`cat $file | grep "^M" | wc -l`
if [ $CHECK -eq 1 ]
then
sed '/^M$/N;s/^M\N//' $file > /tmp/tempfile.tmp
mv /tmp/tempfile.tmp $file
fi
done
Please let me know if any clue or suggestion for making automatic
Try this, beware of the ^M characters, type it as I early mentioned (with vi):
#!/bin/sh
for file in /home/applmgr/test/* ; do
grep '^M' "$file" >/dev/null
if [ $? == 0 ]; then
sed '/^M$/N;s/^M\n//' "$file" > /tmp/tempfile.tmp
mv /tmp/tempfile.tmp "$file"
fi
done