control characters in file - Unix

This is a discussion on control characters in file - Unix ; Hello, I need to verify if a file contains any control characters. Is there a command which i can use. I work on a hp-unix platform. Thanks for your help....

+ Reply to Thread
Results 1 to 2 of 2

Thread: control characters in file

  1. control characters in file

    Hello,
    I need to verify if a file contains any control characters. Is there a
    command which i can use.
    I work on a hp-unix platform. Thanks for your help.


  2. Re: control characters in file

    hanu wrote...

    >I need to verify if a file contains any control characters. Is there a
    >command which i can use.
    >I work on a hp-unix platform. Thanks for your help.


    There are many control characters, including linefeed, which is
    present in almost every text file. So, you need to define what
    control characters you want to detect.

    See this URL for a list of control characters.
    http://en.wikipedia.org/wiki/ASCII#A...rol_characters

    In the following example, xx.txt contains two control characters,
    backspace (\b) and horizontal tab (\t).

    $ cat xx.txt
    123 456
    123 456

    $ od -bc xx.txt
    0000000 061 062 063 040 010 040 064 065 066 015 012 061 062 063 011 064
    1 2 3 \b 4 5 6 \r \n 1 2 3 \t 4
    0000020 065 066 015 012
    5 6 \r \n

    There may be many ways to do what you want; the following example
    use awk.

    $ cat yy.awk
    /\010/ { printf " backspace detected\n" }
    /\011/ { printf " Horizontal Tab detected\n" }

    $ gawk -f yy.awk < xx.txt
    backspace detected
    Horizontal Tab detected

    $


+ Reply to Thread