2

Something strange happened today.
I was connected to an HP server with putty, and saw two files with exact same name:

-rw-r--r-- 1 hemantj 3368 Apr 1 12:47 test
-rw-r--r-- 1 hemantj 20 Sep 1 12:47 test

It was very strange as you can't have files with the same name.

Later when I was connected with FileZilla I saw that there is some special
character at the end of the second file name.

My Question: is it possible to highlight special characters in the file name in a terminal?

I am connected to HP-UX and my shell is tcsh and ksh.

EDIT:

Thanks all for your reply but I think Keymon's solution is the simplest and more portable.
+1 for all of you -- I learned a lot from your responses

4 Answers 4

5

The fact that you're on HP-UX is really the problem. With the GNU tools available on most Linux distributions there are several options.

There is ls -q, which displays special characters as '?'. Or -b which displays octal codes instead.

Another option is ls | cat -v.

Also find . -type f -ls, which displays using escape codes by default.

Some of those might work on HP-UX, but I don't know.

4

I use this:

ls -l | less 
2

If you are lucky enough to have od,

ls -1 | od -xC

ls -1 prints the filenames, separated by a newline. od -xC prints the input text in hexadecimal, with recognisable ascii characters displayed under each octet.

Sample output for three files, named 1, 2, 3:

0000000    310a    320a    330a
           1  \n   2  \n   3  \n
0000006

Sample output for two files, named 1 and '\n2':

0000000    0a32    0a31    0a00
          \n   2  \n   1  \n
0000005

Notice that there are three newlines for two files, and lexographically, "\n2" sorted before "1".

1

this is not a real highlighting, but it might help to identify the characters:

# find . -type f -exec sh -c "hexdump -C <<<'{}'" \;

it might be constructed better. teach me ;)

3
  • no hexdump. :( hexdump: not found
    – Hemant
    Sep 17, 2010 at 11:18
  • BTW can you please explain what above command do ?
    – Hemant
    Sep 17, 2010 at 11:20
  • sure ;) find localizes all files in the directory and executes hexdump. hexdump -C shows the ascii-numbers of the filename on the left and the corresponding ascii-chars on the right. An example output is available at en.wikipedia.org/wiki/Hex_dump (6th sample). I did not know that HP-UX does not have a hexdump, sorry. Google said, the command xd can replace hexdump on HP-UX
    – krissi
    Sep 17, 2010 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .