The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Patterns in Filenames msb65 Shell Programming and Scripting 6 08-01-2008 04:44 PM
spaces in filenames, for do naviztirf Shell Programming and Scripting 4 10-17-2007 05:08 PM
tar contains duplicate filenames dangral UNIX for Dummies Questions & Answers 2 03-14-2007 04:18 PM
Trouble with Backslashes wibo1 Shell Programming and Scripting 0 09-15-2006 04:22 AM
How to echo 4 backslashes more easy ? sun-guy Shell Programming and Scripting 4 08-08-2006 02:07 AM

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 10-28-2008
shepherdsflock shepherdsflock is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Backslashes in Filenames

Using a small script, I automatically generated some text logs. The files ended being undownloadable, unopenable and undeletable. Upon further investigation, the files ended up looking like this:

log\r
log2\r
log3\r

I've tried a few different things, including double slashing before the r in order to try and get these files to be usable. I've adjusted the script so it no longer does this, but I'd like to be able to access these other logs.

Any ideas?
  #2 (permalink)  
Old 10-29-2008
dan-e's Avatar
dan-e dan-e is offline
Registered User
  
 

Join Date: Oct 2008
Location: Brisbane, Australia
Posts: 28
Are the files isolated in a directory?

If so, you could try:
Code:
cat log*
... or something similar. The best way around this problem is probably to use a wildcard match rather than include the \ literal.
  #3 (permalink)  
Old 10-29-2008
shepherdsflock shepherdsflock is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
No. They're not. Let me try that though and see if it does any good.
  #4 (permalink)  
Old 10-29-2008
zaxxon's Avatar
zaxxon zaxxon is online now Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
If it doesn't help, you can try to connect via ftp and delete them from there. Sometimes it allows to use names, which on a shell may not be used or can't be correctly found.
  #5 (permalink)  
Old 10-29-2008
shepherdsflock shepherdsflock is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Yeah.. I tried that. I get critical error. The filenames don't show with the \r so I am certain that is causing some sort of conflict with the filename. I've tried renaming with wildcards. Frustrated.

Thanks for all the suggestions. I do appreciate it.
  #6 (permalink)  
Old 10-29-2008
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,163
Try ls -lab to find out exactly what characters are in the filenames and (more importantly) how many characters are there.
Then "ls" each file with question marks for the doubtful characters to make sure you can refer to the file uniquely.
Then rename (mv) each file - again using question marks for the doubtful characters.
Finally delete the renamed file.
  #7 (permalink)  
Old 10-29-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
Here is a dead-sure way of erasing even the most nastily named file:

get the inode number by using "ls -lai":

Code:
bakunin@machine # ls -lai
246400 drwxr-x---   5 user     staff           256 Oct 21 15:08 .
246236 drwxr-x---   4 user     staff           256 Oct 17 14:26 ..
246237 drwxr-x---   2 user     staff           256 Oct 14 15:50 SPECS
249856 drwxr-x---   2 root     admin           256 Oct 21 15:08 aix
246613 -rw-r-----   1 user     staff          6499 Oct 20 12:45 some_file_with_a_funny_name
Now use the inode for a "find"-command:

Code:
bakunin@machine # find . -inode 246613 -exec rm -f {} \;
Instead of "rm" use whatever command you want to apply to the file. This will even work on files named "..." (yes, this is legal - if you want to torture your sysadmin) or something like that.

But in your case it might be even simpler than that: if the "\r" in the filenames are real character and not the visualization of some nasty control chars (find out by piping "ls -la" to a file and use "set list" in vi to display control codes) then simply escaping the backslash should suffice: "filename\\r" for what is displayed as "filename\r", etc.

I hope this helps.

bakunin
Closed Thread

Bookmarks

Tags
backslashes

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 07:28 AM.


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