Filenames created with '\r' characters at the end


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filenames created with '\r' characters at the end
# 1  
Old 02-11-2009
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  
Old 02-11-2009
Checkout your terminal I/O settings with stty to see if you have some strange terminal mappings.

HTH

Jerry
# 3  
Old 02-11-2009
Quote:
Originally Posted by amio
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching range of filenames witn and without numbers on the end

So I'm grepping for the following right now: ls -la /somedirectory/*.log* | awk '{print $9}' The problem with this is that I get the following output: /somedirectory/errors_1_foo.log /somedirectory/errors_1_foo.log.1 /somedirectory/errors_1_foo.log.2... (4 Replies)
Discussion started by: LinuxRacr
4 Replies

2. Shell Programming and Scripting

Replacing end of line characters

Hello, I'm looking for some help in renaming data-timestamps stored within different calendar directories/files. The calendar directory has hundreds of ICS files: ~/Library/Calendars/F494C908.calendar/Events/92B65E439AAC.ics ~/Library/Calendars/F494C908.calendar/Events/DE7867E61969.ics... (8 Replies)
Discussion started by: Schubi
8 Replies

3. Shell Programming and Scripting

How best to remove certain characters from filenames and folders recursively

hello, I'm trying to figure out which tool is best for recursively renaming and files or folders using the characters \/*?”<>| in their name. I've tried many examples that use Bash, Python and Perl, but I'm not much of a programmer I seem to have hit a roadblock. Does anyone have any... (15 Replies)
Discussion started by: prometheon123
15 Replies

4. UNIX for Dummies Questions & Answers

Removing characters from end of string

Hello, I have records like below that I want to remove any five characters from the end of the string before the double quotes unless it is only an asterik. 3919,5020 ,04/17/2012,0000000000006601.43,,0000000000000000.00,, 132, 251219,"*" 1668,0125 ... (2 Replies)
Discussion started by: jyoung
2 Replies

5. UNIX for Dummies Questions & Answers

find & remove characters in filenames

I have a group of files in different directories with characters such as " ? : in the file names. How do I find these files and remove these characters on mass? Thanks (19 Replies)
Discussion started by: barrydocks
19 Replies

6. Shell Programming and Scripting

Perl: windows filenames escape characters

I have a perl find program that will find all files of window application stored on unix disks. Ofcourse these files contain all the weird characters windows allows, but on *nix pukes out all kinds of unwanted effects when processing these. Is their a utility that will escape all these... (3 Replies)
Discussion started by: karelb
3 Replies

7. Shell Programming and Scripting

Bash script - stripping away characters that can't be used in filenames

I want to create a temp file which is named based on a search string. The search string may contain spaces or characters that aren't supposed to be used in filenames so I want to strip those out. My thought was to use 'tr' with but the result is the opposite of what I want: $ echo "test... (5 Replies)
Discussion started by: mglenney
5 Replies

8. Shell Programming and Scripting

funny characters at the end of file

I'm creating a file in a script : cat > ${SOURCEFILEPATH}/${FILENAME} <<! blahblahblah ! The file that is created has funny characters at the end: ^[[K What is that and how can I get rid of it? (3 Replies)
Discussion started by: achieve
3 Replies

9. Shell Programming and Scripting

Perl code to search for filenames that contain special characters

Hello, I have a requirement to search a directory, which contains any number of other directories for file names that contain special characters. directory structure DIR__ |__>DIR1 |__>DIR2__ |__>DIR2.1 |__>DIR2.2 |__>DIR3 .. ... (8 Replies)
Discussion started by: jerardfjay
8 Replies

10. Shell Programming and Scripting

Removing characters from end of $string

I am writing a script to search PCL output and append more PCL data to the end accordingly. I need to remove the last 88 bytes from the string. I have searched for a few hours now and am coming up with nothing. I can't use head or tail because the PCL output is all on one line. awk crashes on... (3 Replies)
Discussion started by: craig2k
3 Replies
Login or Register to Ask a Question