The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-11-2009
amio amio is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 24
Question Filenames created with '\r' characters at the end

Hi all,
Am creating files and doing copy,compare and deletion.
As i do not want to mention the filepath everywhere, i store the filepaths in variables.

FILENAME="/home/test/create/Myfile.txt"
WR_PATH="/home/test/wrie/writefile.txt"
RD_PATH="/home/test/myread/readfile.txt"
echo "This is my new file" >> $FILENAME
cp $FILENAME $WR_PATH
cp $WR_PATH $RD_PATH
cmp $FILENAME $RD_PATH


My problem is,
The files are created inside the folders with '\r' or '\r\r' characters at the end of the filename and hence cp failed with "No such file or directory"

Observation with -x:
cp /home/test/create/Myfile.txt /home/test/wrie/writefile.txt\r
cp /home/test/wrie/writefile.txt /home/test/myread/readfile.txt\r
cp: cannot stat `/home/test/wrie/writefile.txt' :No such file or directory as there is the file writefile.txt is created as writefile.txt\r

Pls help.
Thanks,
Amio