×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Unable to delete files as sudo

Unable to delete files as sudo

Unable to delete files as sudo

(OP)
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

RE: Unable to delete files as sudo

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."

RE: Unable to delete files as sudo

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close