Operating System - HP-UX
1752577 Members
4284 Online
108788 Solutions
New Discussion

Re: removing odd named file containing non-printing characters

 
SOLVED
Go to solution
Paolo_c
Valued Contributor

removing odd named file containing non-printing characters

Good morning ,

 

 

 

We have an odd named filename (q! ) below which was accidentally created through a VI editing session . and which we're now struggling to remove. if i list the 'filename' (inc nonprinting characters))  it displays the following 

'filename'.

 

 

#ll -lsqb

 

 

-rw-r--r--   1 root       sys            540 Sep 29 15:43  \177q! 

 

 

 

Could someone please suggest a  method I could employ to safely remove (or rename) this file ?  

 

 

 

thanks

Paul 

 

4 REPLIES 4
Steven Schweda
Honored Contributor

Re: removing odd named file containing non-printing characters

   If you can tolerate a little interactivity:

      rm -i *'q!'

   If:
      ls *'q!'
shows only one file, then the "-i" isn't really needed.

> [...] (or rename) [...]

   That may harder.  "mv" has a "-i" option, but (typical of UNIX) it
has different semantics.  If you can find a wildcard expression which
catches only the target file, then it's easy.

RJHall
Frequent Advisor

Re: removing odd named file containing non-printing characters

Another approach is to delete by inode number:

 

ls -li *q!

4739 ...

 

then use find to locate the file by inode number and perform the rm:

 

find . -inum 4739 -exec rm -i {} \;

Dennis Handly
Acclaimed Contributor
Solution

Re: removing odd named file containing non-printing characters

>-rw-r--r--   1 root       sys            540 Sep 29 15:43  \177q! 

 

This is a Del char.  So you can simply type: rm -i ?q!

And hopefully there is only one.

 

Or you could use tr(1) to get that Del:

$ rm -i $(echo "Aq!" | tr "A" '\177')

Or

$ mv $(echo "Aq!" | tr "A" '\177') bad_file

 

Or look at the tag cloud:

http://h30499.www3.hp.com/t5/tag/unprintable%20chars/tg-p/category-id/operating_systems

Paolo_c
Valued Contributor

Re: removing odd named file containing non-printing characters

many thanks for the feedback provided.  I didn't realise that this was a DEL char but the workaround provided  worked fine. thanks also to everyone else that provided feedback.