Operating System - HP-UX
1753697 Members
5107 Online
108799 Solutions
New Discussion

Need to remove file named @

 
SOLVED
Go to solution
Paul Maglinger
Regular Advisor

Need to remove file named @

I've got a file in my root directory called @.  I have searched and found references where you find the inode of the file and then remove it using the find command.  The ls -il command works fine to find the inode, but I'm leery of the command line they are using to delete the file.  They want to use:

root # find . -inum <inode> -exec rm -i {} \;

 

If I just do

root # find . -inum <inode>

 

it comes back with several files but none of them are the file (or in the directory) that I want to delete.

 

Does anyone have a nice, safe way to delete this file?  Running HP-UX 11.23.

 

thanks!

8 REPLIES 8
Dennis Handly
Acclaimed Contributor

Re: Need to remove file named with unprintable @

First of all, what is the exact name of the file, since you may have some unprintable chars in it?

ll -b

 

># find . -inum <inode>

>it comes back with several files but none of them are the file (or in the directory) that I want to delete.

 

If you only want to search the current filesystem, use: -xdev

Only the current directory:

find . ! -name . -prune -inum <inode>

 

You could just use rm, if you don't have lots of files with "@" in them: rm -i *@*

 

 

 

Paul Maglinger
Regular Advisor

Re: Need to remove file named @

 

This is what I'm seeing.  There are other files in the directory, I just omitted them from the ll listing.

 

># ll

-rw------- 1 root sys 5449 Sep 10 2007 @

># ll -b

-rw------- 1 root sys 5449 Sep 10 2007 \300

># ll @

@ not found

># ll -i "@"

@ not found

># rm -i "@"

rm: @ non-existent

># ll -b "@"

@ not found

># ll -i

3165 -rw------- 1 root sys 5449 Sep 10 2007 @

Steven Schweda
Honored Contributor

Re: Need to remove file named @

 
Bill Hassell
Honored Contributor

Re: Need to remove file named @

 You wrote:

 

># ll
-rw------- 1 root sys 5449 Sep 10 2007 @
># ll -b
-rw------- 1 root sys 5449 Sep 10 2007 \300

 The -b option shows characters in the filename that are not part of the displayable ASCII characters. In this case, \300 means octal 300. From the man page for ascii, you can see that 100 octal is indeed the @ character, but if the parity bit is on, then the octal value is 300. So most terminal emulators will show octal 100 and 300 the same way as @. The reason that you can't remove it is that you are typing @ from your keyboard and the parity bit is turned off, so the character doesn't match.

 

So this will take a bit of cleverness to remove. Probably the easiest is to remove one-character files using the -i option like this:

 

rm -i ?

 This will match all one character filenames.

When the rm comand asks if you want to remove @ then you answer yes and the file will be gone.

 



Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Need to remove file named with unprintable @

>-rw------- 1 root sys 5449 Sep 10 2007 \300

 

It looks like you have "@" with the parity bit set.

I don't know if you can cut&paste that 8 bit char but if you can, just use "rm -i paste-char".

Or you can redirect the ll output, delete all lines and words but that char.  Then try:

rm -i $( < file)

 

You could also look into vis(1) & inv(1), tr(1) or awk to get that char.

 

Did you retry that find suggestion?

 

Or go with Bill's suggestion of "rm -i ?".

 

>If you can disrupt access to this directory briefly,

 

Probably not if it is /.  :-)

Steven Schweda
Honored Contributor

Re: Need to remove file named with unprintable @

 
Paul Maglinger
Regular Advisor
Solution

Re: Need to remove file named @

Never mind, I got it.  I had to go in through the GUI file manager and delete it that way.

Paul Maglinger
Regular Advisor

Re: Need to remove file named with unprintable @

Thanks Steven.  That's exactly the character that showed up in the file manager.  Not sure how it got there, but glad to be rid of it.

 

-Paul