Posts Tagged command

How to remove/move/copy/rename file that has a non-printable name

How to remove/move/copy/rename file that has a non-printable name, for example:

backup@root:/home/userhome/test # ls -la
total 2
-rw-rw-rw- 1 root sys 0 Sep 23 15:48
drwxrwxrwx 2 root sys 96 Sep 23 15:50 .
drwxr-xr-x 5 userhome adm 1024 Sep 23 16:20 ..
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 -test

The easiest one is the file named "-test", you can do a "mv -- -test xx" to rename it to test, getting rid of the "-".

The most annoying is the other file, which apparently has the name "blank", but not quite.

There are two ways to find the real file name.,"ls -lq" e "ls -lb":

backup@root:/home/userhome/test # ls -lq
total 0
-rw-rw-rw- 1 root sys 0 Sep 23 15:48 ?
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
backup@root:/home/userhome/test # ls -lb
total 0
-rw-rw-rw- 1 root sys 0 Sep 23 15:48 \002
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
backup@root:/home/userhome/test # ls -li
total 0
17334 -rw-rw-rw- 1 root sys 0 Sep 23 15:48
17332 -rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx

The "ls -lb" shows the non-printable characters with "\ XXX" where XXX is the ASCII representation of the non-printable character.
The "ls -lq" shows the non-printable characters with "???" (quantity of ? is defined by the amount of non-printable caracters).
The "ls -li" shows the file inode.

To handle this file, the best option is to use the "find".

- Using the find based on the inode:
find . -inum 17334 -exec mv {} asd \;

- Using find with "wildcards" (based on the ls-lq returned):
find . -type f -name "?" -exec mv {} asd \;

Be careful when using the find with "meta character"! If a file whose name has only one character, it will enter the result.
 

, ,

No Comments

Check powerpath links in HP-UX

To check if the powerpath links are up in HP-UX, you can use the following command:

# powermt display dev=all

 

, , ,

No Comments