Operating System - HP-UX
1752511 Members
4913 Online
108788 Solutions
New Discussion юеВ

Re: A file with the filename ~

 
SOLVED
Go to solution
Subentu
Frequent Advisor

A file with the filename ~

Hi guys,

I have a file with the filename ~ in one of my HP-UX directories. I have no idea how it was created and how to delete it.

-rw-r--r-- 1 bscsprod bscsprod 524324 Nov 18 21:09 localhost_log.2008-11-18.txt
-rw-r--r-- 1 bscsprod bscsprod 16806 Nov 19 09:57 localhost_log.2008-11-19.txt
-rw-r--r-- 1 bscsprod bscsprod 0 Nov 19 10:09 ~


It would be great if anyone can explain what is that file and how to remove it.

Thanks in advance
5 REPLIES 5
Suraj K Sankari
Honored Contributor
Solution

Re: A file with the filename ~

Hi,

Go the desire directory where this file is laying and give
rm -i *
now you have a choice to remove one bye one when ~ file came press y and enjoy

Suraj
Venkatesh BL
Honored Contributor

Re: A file with the filename ~

'~' char is used in shell to refer to once home directory.

>rw-r--r-- 1 bscsprod bscsprod 0 Nov 19 10:09 ~

The size of the file being '0' hints that it was created by mistake, while executing a file creation command and passing the home dir reference as '~'

You can remove it by using:
# rm "~"
Hein van den Heuvel
Honored Contributor

Re: A file with the filename ~

The interactive remove is often simple and effective... but I hope there are not too many files as ~ sorts at the end of the alphabet :-). So yu may want to use ? instead of *.

Now tilde substitution happens at the begin of word. So just use ./~ ?

With 'testdrive' gone I lost easy HPUX access to try stuff, but I also expect \~ to work

fwiw,
Hein
Anka
Trusted Contributor

Re: A file with the filename ~

The file can be created for example with:

#touch -- \~

Then listed with:

#ll -- \~

Then removed with:

#rm -i -- \~
Frank de Vries
Respected Contributor

Re: A file with the filename ~

A little trick that works also for other
files of special nature :

In the directory do

ls -1 > out.lst
vi out.lst and remove all entries except your ~

then run a for loop to remove the entry

for i in $(cat out.lst)
print $i
rm $i
done

Look before you leap