Special Characters in directory name


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Special Characters in directory name
# 1  
Old 08-11-2006
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  
Old 08-11-2006
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  
Old 08-11-2006
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  
Old 08-11-2006
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  
Old 08-14-2006
Unfortuantly we do not have perl and the personnel directory is in constant use so cannot rename.

Any other ideas would be appreciated.
# 6  
Old 08-14-2006
May be it will help you.....just put a double quote to escape the octals....

rmdir "dir/asdasdasdasa\asdalsdada/withlongname"


regards
Apoorva Kumar
# 7  
Old 08-14-2006
tez,
The easiest way to remove it is to do a rm -ri personnel*, this should prompt you for every file/directory, find if there is anything in the directory, just use find, ie if there is not much in the parent directory just do a find . -print.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to replace special characters?

Hi Team, I have data like this. |*|.5|*|0.2|*|A.B|*| Would like to add zero (0) before the decimal point where there is no zero as |*|0.5|*|0.2|*|A.B|*| How to replace |*|. with |*|0. I tried below command which didn't work echo '|*|.5|*|0.2|*|A.B|*' | sed... (4 Replies)
Discussion started by: Ravi.K
4 Replies

2. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

3. Shell Programming and Scripting

special characters

Hey guys, I'm trying to replace "]Facebook" from the text but sed 's/]Facebook/Johan/g' is not working could you please help me with that? (6 Replies)
Discussion started by: Johanni
6 Replies

4. UNIX for Dummies Questions & Answers

How to see special characters?

Hi all, I was wondering how can i see the special characters like \t, \n or anything else in a file by using Nano or any other linux command like less, more etc (6 Replies)
Discussion started by: gvj
6 Replies

5. Solaris

How to remove a directory or file with special characters in Solaris

I finally figured out how to remove a file or directory with special characters in the name. It's kind of rudimentary so I thought I would share it with everyone: find .inum -exec rm -rf {} \; (7 Replies)
Discussion started by: jastanle84
7 Replies

6. Shell Programming and Scripting

Special characters

When I open a file in vi, I see the following characters: \302\240 Can someone explain what these characters mean. Is it ASCII format? I need to trim those characters from a file. I am doing the following: tr -d '\302\240' ---------- Post updated at 08:35 PM ---------- Previous... (1 Reply)
Discussion started by: sid1982
1 Replies

7. UNIX for Dummies Questions & Answers

help on vi (special characters) needed

How to add characters (not on the keyboard) with vi to a file? Example: How can I enter the copyright sign (UTF-8-Codetable: 169) with vi? (3 Replies)
Discussion started by: desertchannel
3 Replies

8. UNIX for Dummies Questions & Answers

Remove directory that has special Characters

Hi All, I have a script written that creates a new directory within the shell program and if a parameter isn't passed in, it creates a strange directory name by mistake. So I have a directory like "-_12" and I am unable to remove it. I tried removing it using double quote and many others. I have... (12 Replies)
Discussion started by: datherriault
12 Replies

9. UNIX for Dummies Questions & Answers

Array with special Characters

Hi, I would write a shell script to execute a series of command. However, if the cmd contains "-" in the array. It fails to do so. I'd tried use ', " or \ but get the same result. Output: (1 Reply)
Discussion started by: donaldfung
1 Replies

10. UNIX for Dummies Questions & Answers

special characters

I have one file which is named ^? ( the DEL character ) I'd like to know how to rename or copy the file by using its i-node number TYIA (2 Replies)
Discussion started by: nawnaw
2 Replies
Login or Register to Ask a Question