Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, I have special character ^@ at my ksh script. It is running on HP-UX,SunOs,AIX but on Linux it is failing. The script is : Code: > cat -v test.ksh ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    6

    remove special characters ^@ in ksh script

    Hi,

    I have special character ^@ at my ksh script.
    It is running on HP-UX,SunOs,AIX but on Linux it is failing.

    The script is :

    Code:
    > cat -v test.ksh 
    #! /bin/ksh
    echo ^@test^@
    When i running it , i get the following error:

    Code:
    > ./test.ksh 
    ./test.ksh: syntax error at line 2: `zero byte' unexpected
    What is this character and how can i remove it (may be by sed).

    Thanks a lot

  2. #2
    Just Joined!
    Join Date
    Apr 2007
    Posts
    59
    You can remove it using sed like this:

    Code:
    cat test.ksh | sed 's/^@//g' > test2.ksh
    mv test2.ksh test.ksh

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    6
    ^@ it is not 2 characters, it 's one special character like ^M.

    i already found the answer:

    ^@ in ascii (Hexadecimal ) it's 00

    so the solutin is

    Code:
    sed 's/\x00//g' file
    Thanks.

  4. #4
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Quote Originally Posted by sandeep t View Post
    You can remove it using sed like this:

    Code:
    cat test.ksh | sed 's/^@//g' > test2.ksh
    mv test2.ksh test.ksh
    That can't work, since "/^@/" means "@" at the beginning of a line.

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    That can't work, since "/^@/" means "@" at the beginning of a line.
    burschik is correct from two angles:
    1. He knows his stuff, and (no surprise) his stuff here is correct.
    2. Just for fun, I tried it, and he's right.

    And with:
    Code:
    sed 's/\x00//g' file
    alexvai is correct; I tried that one, too.

    But sandeep t is almost there as well. This will work:
    Code:
    cat test.ksh | sed 's/\c@//g' > test2.ksh
    but this is better:
    Code:
    sed 's/\c@//g' test.ksh > test2.ksh
    You can find additional information on "useless uses of cat" here.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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