Operating System - HP-UX
1748203 Members
3277 Online
108759 Solutions
New Discussion юеВ

Reading and then deleting files that have invisible charcaters in their names

 
Andrew Kaplan
Super Advisor

Reading and then deleting files that have invisible charcaters in their names

Hi there --

We have several files that have titles where there are invisible characters. One example of this would be a file that has the delete key character in its name. These are files that were created by mistake.

How can I go about reading what is in these files, and then subsequently removing them? Thanks.
A Journey In The Quest Of Knowledge
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

If the name is somewhat unique, try using wildcards.

If the file is file1, where the are the delete characters, then try

# more file*1

or

# more fi*1

Just experiment until you get the right combination.

To delete just supply the same wildcard name you used above. I would use the '-i' option to 'rm' so it will ask you if you are sure you want to delete.

# rm -i fi*1
James R. Ferguson
Acclaimed Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

Hi Andrew:

Another way to handle files like this is to find their inode number with 'ls' and use that to read and/or remove them:

# cat /etc/hosts >> "/tmp/bad file "
# ls -i /tmp/bad*
7130 /tmp/bad file
# find /tmp -xdev -inum 7130 -exec cat {} \;
...lists the file's contents...

# find /tmp -xdev -inum 7130 -exec rm -i {} \;
...removes the file...

Remember that an inode value is only unique within a filesystem!

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

You can use "ll -b" to list these files or pipe your ls result to vis(1). You'll see "\###" (octal) for each unprintable char with -b.

Here are a bunch of other threads that tell you how to remove or rename the file/directory:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1255548
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1180587
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1161638
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=954241
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=486327

>would be a file that has the delete key character in its name.

If you have the right stty setting, DEL is just a normal char that you can enter.
ManojK_1
Valued Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

Noramally it is very difficult. Because the invisible character can come anywhere in the file name,at the start of file name also!

Normally to find out and delete the file i am using winscp from an windows system. This graphic based scp tool will give the actual file name with all the junk characters. I am renaming or deleting the file through this tool.

Thanks and Regards,
Manoj K
Kapil Jha
Honored Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

In the directory having bad files do
#ls -lrt>file1
#vis file1 this should show you invisible characters in the file name.

now delete all the files which are bad.Be sure to use
single coats else could affect other files if they share same format of name.

rm 'file'

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Suraj K Sankari
Honored Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

Hi,

The best option is remove this type of junk character or hidden character file from a directory is:

go to the respective directory

rm -i *

then one by one it will ask for delete or not ................

Suraj
V. Nyga
Honored Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

Hi,

... or use the file manager of CDE and move the file to the trash.

Volkmar
*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: Reading and then deleting files that have invisible charcaters in their names

Hi Andrew,

from your profile:
You have assigned points to 127 of 649 responses to your questions.

Please read this one:
http://forums12.itrc.hp.com/service/forums/helptips.do?#28

V.
*** Say 'Thanks' with Kudos ***