The UNIX and Linux Forums  

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
parsing filenames jville UNIX for Dummies Questions & Answers 3 11-04-2008 05:15 PM
Backslashes in Filenames shepherdsflock UNIX for Dummies Questions & Answers 6 10-29-2008 12:58 PM
spaces in filenames Bab00shka Shell Programming and Scripting 8 09-30-2008 03:13 PM
tar contains duplicate filenames dangral UNIX for Dummies Questions & Answers 2 03-14-2007 04:18 PM
Perl code to search for filenames that contain special characters jerardfjay Shell Programming and Scripting 8 01-19-2006 04:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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
  #2 (permalink)  
Old 02-11-2009
JerryHone JerryHone is offline
Registered User
  
 

Join Date: Nov 2006
Location: UK
Posts: 178
Checkout your terminal I/O settings with stty to see if you have some strange terminal mappings.

HTH

Jerry
  #3 (permalink)  
Old 02-11-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,378
Quote:
Originally Posted by amio View Post
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.

Please put code inside [code] tags.
Quote:


Code:
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"

Did you write the script using a Windows editor? If so, you must remove the carriage returns before you execute the script on a real computer.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0