![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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". |
|
||||
|
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 |
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|