cp produces odd file name ending in "?"

Ken Burtch kburtch-Zd07PnzKK1IAvxtiuMwx3w at public.gmane.org
Sat Dec 16 00:55:20 UTC 2006


On Fri, 2006-12-15 at 19:00 -0500, Alex Maynard wrote:

> The strange thing is a number of the files, such as
> simuvolk/stock/campbell/LHREGHH.G end up having a "?"
> at the end of the filename after they are copied.
> 
> When I use the tab to type the file name this "?" becomes
> a "^M"

This hasn't happened to me.  However, "^M" is often a short-form for
"Control-M" or a carriage return.  Windows and Macintosh text files use
carriage returns at the end of line.  Linux uses a line feed character.
If you created the script on Windows or a Macintosh OS, or if you
copied-and-pasted the filenames from Windows or a Mac window but
accidentally copied the end of the line along with the filename (where
the black highlight extends to the right edge of the window), there
might be stray carriage returns in the script.  On Linux the shell
interpreter might think a stray carriage return at the end of the line
is a part of the destination file name.

To remove all carriage returns, use a command like

  tr -d '\r' < original.txt > result.txt

and see if the file size changed as a result with ls -l.

That would be a place to start.

KB

-- 
-----------------------------------------------------------------------------
Ken O. Burtch                                    Phone/Fax: 905-562-0848
  "Linux Shell Scripting with Bash"               Email: ken-8VyUGRzHQ8IsA/PxXw9srA at public.gmane.org
  "Perl Phrasebook"                         Blog: http://www.pegasoft.ca
-----------------------------------------------------------------------------


--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list