Operating System - HP-UX
1834789 Members
2694 Online
110070 Solutions
New Discussion

Re: how to delete a file which has no name.............

 
jhingoor
Frequent Advisor

how to delete a file which has no name.............

Thanks in advance,
one of my colleagues was trying to edit a log file..by doing vi check.log...He got a message permission denied...after which he quit the editor by :wq as a result of which a file is created which is 0 bytes ..but no name...

Now i want to delete tht file..how do i do it.????/

The ouput is as follows.........

-rw------- 1 xyz users 0 May 21 08:0
12 REPLIES 12
Arunvijai_4
Honored Contributor

Re: how to delete a file which has no name.............

Hi,

You can delete using inode number,

1) Find out inode number of the file using ls -i

2) Delete using find . -inum [inode-number] -exec rm -i {} \;

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Hemmetter
Esteemed Contributor

Re: how to delete a file which has no name.............

Hi jhingoor,

you can do a "ls -q" you will see all the unprintable character of that filename as "?".

After that you can delete it with (e.g.)

rm -i ./?????

Be shure to delete interactive "-i" to not delete other files with same filenamelength.

rdgs

HGH

Indira Aramandla
Honored Contributor

Re: how to delete a file which has no name.............

Hi Jhingoor,

You can use ls -i option to list the file and the corresponding inode number.

You can get the inode number of the file that you wanted to delete then use find with â inum option to lits first, check and then delete.

Eg: if the inode number of the file is 4568

find /path -inum 4568 -exec ll {} \;
Check that this is the file you want to delete and then
find /path -inum 4568 -exec rm {} \;

Note that file serial numbers are unique only within a given file system


IA
Never give up, Keep Trying
Sivakumar TS
Honored Contributor

Re: how to delete a file which has no name.............

Hi,

One way is to find the inode number and delete using the same.

# ls -i *

3555 testfile

then,

# find . -inum 3555 -exec rm {} \;

Regards,

Siva.
Nothing is Impossible !
jhingoor
Frequent Advisor

Re: how to delete a file which has no name.............

Thanx guys...but the problem is that the inode shown is 1 with no filename.......

and find /xyz -inum 1 -exec ls -la {} \;


shows nothing.............
V. Nyga
Honored Contributor

Re: how to delete a file which has no name.............

Hi,

you could use the file manager of CDE to edit the file name.

Then you can erase it normal.

By the way the '1' in your line
-rw------- 1 xyz users 0 May 21 08:0
is *not* the inum of your file!

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
john korterman
Honored Contributor

Re: how to delete a file which has no name.............

Hi,

please post the output of:

# ls -il | cat -v


regards,
John K.
it would be nice if you always got a second chance
V. Nyga
Honored Contributor

Re: how to delete a file which has no name.............

Hi again,

what does ls -il says?

Btw - Siva - 'find . ' is not so good because it would search all subdirectories.
Better would be './'

In general there are many threads here with similar problems, you should try some suggestions:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1012446
*see also Rick's comment about 'find .' *
http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=108346

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
jhingoor
Frequent Advisor

Re: how to delete a file which has no name.............

ls -il|cat -v gives ....

-rw-------1 sureshs users 0 May 21 08:01 ^?^?
V. Nyga
Honored Contributor

Re: how to delete a file which has no name.............

Hi,

ls -l gives for example:
-rw-rw-r-- 1 root sys 203264 Nov 15 2004 xdriver.ini
ls -il gives:
83153 -rw-rw-r-- 1 root sys 203264 Nov 15 2004 xdriver.ini

So 83153 is the inum of the file xdriver.ini

You can use rm -i * or as I suggested use the file manager, there you can see files like ^?^?

V.
*** Say 'Thanks' with Kudos ***
john korterman
Honored Contributor

Re: how to delete a file which has no name.............

Hi again jhingoor,

what kind of system do you have - the output from "ls -il" does apparently not show the inode number of the file, which should have appeared leftmost (the '1' listed is the number of links to the file).

Another approach is to try and list the file using different wildcards , e.g. enclosed in single quotes, e.g.:
# ls -l '^*'
or for a certain number of chars:
# ls -l ????
or other combinations and then replace ls by rm when you can match only the file in question. However, the other suggestions are better.

regards,
John K.
it would be nice if you always got a second chance
James R. Ferguson
Acclaimed Contributor

Re: how to delete a file which has no name.............

Hi:

The inode is not one. You need to do:

# ls -il (that's a lowercase "i" as in "inode" and a lowercase "l" as in "list" to list more information.

The inode number is the number in the *first* column.

Inode numbers are only unique within a filesytem. That is, the same numbers will apply to files in different filesystems.

Regards!

...JRF...