Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to delete files as sudo

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
ls -la shows a bunch of files in a temp directory.
Any time I try to modify the directory, it lists every file within that directory and tells me "no such file or directory" for each one.

I'm thinking the issue has to do with the file names, which contain '^%'. Even surrounding the file name with quotes it tells me the file does not exist.. yet here it is.

Any hints?

-Stephen
 
That sounds strange.
Have you tried escaping the special chars with '\'
Eg. My_wierd\^\%_file

What are you running to 'modify the directory'?


"If you always do what you've always done, you will always be where you've always been."
 
Just for reference, for any files that have strange characters or are difficult to delete I use ..

# ls -larti (the i = inode)

So lets make a file with a space in its name ...

Code:
HP-650-Notebook-PC:~$ touch " opps.txt"

try to ls it as it looks like its just called opps.txt ...

Code:
HP-650-Notebook-PC:~$ ls opps.txt
ls: cannot access opps.txt: No such file or directory

Now lets list the files ending in .txt with their inode number (inum) ......

Code:
HP-650-Notebook-PC:~$ ls -irthl *.txt
6825593 -rwxrwxr-x 1 fred fred 2.4K Aug 18 08:58 domains.txt
6825592 -rw-rw-r-- 1 fred fred 2.8K Aug 18 09:35 domains_new.txt
6827069 -rw-rw-r-- 1 fred fred    5 Jan  6 21:44 whatswhat.txt
6827143 -rw-rw-r-- 1 fred fred    0 Jan 15 21:00  opps.txt
HP-650-Notebook-PC:~$

Once you have the inode (number) you can delete it with:

Code:
HP-650-Notebook-PC:~$ find . -inum 6827143 -exec rm {} \;

Lets look again ??? yup its gone :) ......

Code:
HP-650-Notebook-PC:~$ ls -irthl *.txt
6825593 -rwxrwxr-x 1 fred fred 2.4K Aug 18 08:58 domains.txt
6825592 -rw-rw-r-- 1 fred fred 2.8K Aug 18 09:35 domains_new.txt
6827069 -rw-rw-r-- 1 fred fred    5 Jan  6 21:44 whatswhat.txt
HP-650-Notebook-PC:~$

IHTH

Laurie.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top