Find the answer to your Linux question:
Results 1 to 5 of 5
Hi. I have files in my OS that has wierd file names with not-conventional ascii characters. I would like to run them but I can't refer them. I know the ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5

    Wierd Ascii characters in file names

    Hi.
    I have files in my OS that has wierd file names with not-conventional ascii characters.
    I would like to run them but I can't refer them.
    I know the ascii # of the problematic characters.

    I can't change their name since it belongs to a 3rd party program... but I want to run it.

    is there anything like :
    ./procc"/45"sds.sh ?
    doesn't work for me.

    thanks,

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    The first step is to know whether you "know" the value of the ASCII character in decimal, octal, or hexadecimal. For example, the value of the ASCII character "5" can be expressed thus:
    1. in decimal: 53
    2. in octal: 65
    3. in hex: 35

    To see how this works for all members of the ASCII character set, do this at the command prompt:
    Code:
    man ascii
    But that won't help you, because the character in which you're interested has its most significant bit set, so it's not a member of the ASCII character set.

    I recommend that you use the octal representation of any non-ASCII character in a filename, because the program ls lets you discover its value easily. Consider this demonstration from real life, formatted to fit your television screen:
    Code:
    wally:~/sunday/1$ # You can find all filenames with non-ASCII characters thus:
    wally:~/sunday/1$ 
    wally:~/sunday/1$ ls
    a?c  t1
    wally:~/sunday/1$ 
    wally:~/sunday/1$ # See the question mark?  That means that the character is
    wally:~/sunday/1$ # either an actual question mark or a non-ASCII character.
    wally:~/sunday/1$ 
    wally:~/sunday/1$ # Let's find the octal representation of that character.
    wally:~/sunday/1$ 
    wally:~/sunday/1$ ls -b
    a\241c	t1
    wally:~/sunday/1$ 
    wally:~/sunday/1$ # We can refer to that file explicitly thus:
    wally:~/sunday/1$ 
    wally:~/sunday/1$ ls -l a$'\241'c
    -rwx------    1 wally    wally          60 Oct  7 06:02 a?c
    wally:~/sunday/1$ 
    wally:~/sunday/1$ # Of course, if it's a program, we can run it thus:
    wally:~/sunday/1$ 
    wally:~/sunday/1$ a$'\241'c
    This is a program whose program file has a funny name.
    wally:~/sunday/1$
    You might not need to know the exact value of the non-ASCII character. If you specify the directory exactly, or if the program is in your current directory, and there's only one file whose name consists of "a", some other character, and "c", you can run that program thus:
    Code:
    a?c     # This assumes that . is part of your $PATH.
    or
    Code:
    some/directory/or/other/a?c
    or
    Code:
    /some/directory/or/other/a?c
    That will work no matter what the second character is, whether it's in the ASCII character set or not.

    Hope this helps.

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5

    Solaris ?

    Thanks a lot !
    It worked perfectly on my linux box.

    however - it doesn't work on my Solaris machine.
    Do you know how I can implement it there ?


    on linux :

    [root@localhost ~]# echo $'\x6c\x73'
    ls

    On solaris :
    # echo $'\x6c\x73'
    $\x6c\x73


    thanks.

  4. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    What shell are you running on Solaris? You're relying in the shell doing the character interpretation, and you're probably not using bash, but either a vanilla Bourne shell (sh) or the primitive 88i(?) Korn shell (ksh) that Solaris ships with.

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I fear that scm's right.

    Got Perl on that Solaris system? If you do, try this at your shell command prompt:
    Code:
    perl -e 'system("echo \x6c\x73") && die $!'
    This should work for any version of Perl, even Perl 4.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...