1

Sorry if I am not using the right terms for naming these "backspace chars".

I would like to clean up a directory that contains two files which looks like they contain backspace in their name. If I list the directory:

ls -la

I get this:

-rwxrwxrwx    1 guy guy        729 Jun 26 2007  z_regular.mk
-rwxrwxrwx    1 guy guy          1 Sep  7 2016
-rwxrwxrwx    1 guy guy       3220 Sep 27 2

I am thinking I mistakenly imputed the file names with "backspace chars", so we do not see the names any more.

How do I rename these last two files?

I don't know how to call them. Is there an ls option allowing me to display the file names in hexa or something, and how could I use the latest in an mv command? I'm with AIX Unix TLS v6.

edit:

the files are respectively 2 and 4 del chars:

ls -lb

gives

-rwxrwxrwx    1 guy guy          1 Sep  7 2016   \177\177
-rwxrwxrwx    1 guy guy       3220 Sep 27 2      \177\177\177\177\177

But solutions found at How can I delete a file with no name doesn't work for my case in AIX.

I tried the below without success so far:

l>ls -l $'\0177\0177'
$\0177\0177 not found
l>ls -l '\0177\0177'
\0177\0177 not found
l>ls -l '\177\177'
\177\177 not found
J. Chomel
  • 241

2 Answers2

4

The $'\ooo' syntax (from ksh93 and now found on most modern Bourne-like shells including zsh, bash, mksh, FreeBSD sh) uses the standard (as in C and most other languages) as opposed to echo syntax for octal escapes. So, that's \ followed with up to 3 octal digits: $'\177'. $'\0177' would be like $'\017'7. So:

ls -ld $'\177\177'
mv $'\177\177' better-name

(note that \177, aka ^? or DEL character in ASCII, is not the Backspace/^H/BS/\10 character)

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
0

I found solution at the bottom of suggested duplicate:

  1. identify node numbers

    ls -lbi
    
    25553  -rwxrwxrwx    1 guy guy          1 Sep  7 2016   \177\177
    25559  -rwxrwxrwx    1 guy guy       3220 Sep 27 2      \177\177\177\177\177
    
  2. then it's possible to move when returned from find:

    find . -inum 25553  |xargs -I{} mv {} recovered.x
    find . -inum 25559  |xargs -I{} mv {} recovered.y
    
J. Chomel
  • 241