On SunOS I have directories with names containing only non-printable characters. The command
ls -ldb *
returns the following (some spaces deleted)
drwxr-xr-x 3 user1 group1 3 Feb 4 18:10 \0122011\0122016\0122016\0122016\0122011\0122011\0122011\0122011\0122011\0122011\0122016\0122011\0122012/
drwxr-xr-x 3 user1 group1 3 Feb 4 11:03 \0122016\0122016/
How can I rename these directories?
Best Answer
Similar text as
ls -ldb *
could be produced by (ksh, bash, zsh)$'...'
, as this:Which is just a bunch of new-lines (Oct 012, Hex 0x0A) and years.
If limited on the shell you could use, then use printf :
Note that the above code does not include the last
/
. Which in fact is not needed to give the name of the directory to the kernel.So, to erase, use:
To rename use:
The other file will need this:
Or, if there are not other files with a similar name, a shorter string: