The UNIX and Linux Forums  


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
Remove directory that has special Characters datherriault UNIX for Dummies Questions & Answers 12 01-14-2009 05:53 PM
help on sed replacing special characters prvnrk Shell Programming and Scripting 11 10-01-2008 12:02 PM
unescaping special characters sriram_r Shell Programming and Scripting 3 02-06-2008 07:59 AM
special characters nawnaw UNIX for Dummies Questions & Answers 2 05-18-2004 04:17 PM
awk/sed with special characters apalex Shell Programming and Scripting 5 05-06-2002 05:40 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 08-11-2006
tez tez is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 11
Special Characters in directory name

Hi all,

I've got a couple of directorys with special chars in the name:

# ls -q
personnel?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D?[D

unilive_?[B?[H?[L?[F?[L?[L?[Lpwd

I do not know how to get into these directorys to check if anything is their before deleting. Also I do not know ho wto delete these directorys.

Any help would be greatful!

Cheers
  #2 (permalink)  
Old 08-11-2006
nathan nathan is offline VIP Member  
Supporter
  
 

Join Date: Jul 2006
Posts: 156
To help determine what the characters are, I would use the '-b' option with ls.

Code:
       -b, --escape
              print octal escapes for nongraphic characters

For filenames with special characters, I think it's easiest to use a typeglob. Do you have any other files that start with "personnel"? If not,
Code:
cd personnel*

would probably place you in that directory. Then just use 'ls' to see if it has files.


Code:
rmdir personnel*

would attempt to delete the directory, and would complain if it contained any files. Just make sure you don't have any other directories that start with "personnel".
  #3 (permalink)  
Old 08-11-2006
tez tez is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 11
Unfortunatly I do have another folder called personnel hence cannot do rmdir personnel*

ls -b
personnel\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D
  #4 (permalink)  
Old 08-11-2006
nathan nathan is offline VIP Member  
Supporter
  
 

Join Date: Jul 2006
Posts: 156
Do you have Perl? Something like this might work. You would have to uncomment the rmdir line, but I would recommend this only after you know it's printing only the directory name you want to delete.

Code:
#!/usr/bin/env perl

my @files = glob("personnel*");

# 27 decimal = 33 octal
$char = sprintf("%c",27);

foreach $file ( @files ) {
   if ( $file =~ m/personnel$char/ ) {
     printf "dir = $file\n";
     # rmdir $file;
   }
}

I'm sure there's a way to escape octal characters in the shell, but I'm not sure how. Another alternative would be to move off all the 'normal' directories to a temporary location until the only one left is the "personnel\033[D.." file. Then rmdir personnel* as above.
  #5 (permalink)  
Old 08-14-2006
tez tez is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 11
Unfortuantly we do not have perl and the personnel directory is in constant use so cannot rename.

Any other ideas would be appreciated.
  #6 (permalink)  
Old 08-14-2006
apoorvasharma80 apoorvasharma80 is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 69
May be it will help you.....just put a double quote to escape the octals....

rmdir "dir/asdasdasdasa\asdalsdada/withlongname"


regards
Apoorva Kumar
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 10:59 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