cat –v $filename | sed –e ‘s/\^@/ /g’ > filename.dat

Posted on 2005-04-28
Last Modified: 2010-08-05
Can some one please explain what the below stmt does
cat –v $filename | sed –e ‘s/\^@/ /g’ > filename.dat

any help would be greatly appreciated
Question by:bsippy
    LVL 14

    Accepted Solution

    >> cat
    display contents of a file

    >> -v
    also display nonprinting characters

    >> $filename
    this is an environmental variable containing a filename

    >> |
    (pipe): redirect the output to the command that follows this

    >> sed
    'stream' (text file) editor

    >> -e

    >> ‘s/\^@/ /g’
    regular expression:

    >> s

    >> /\^@/ /
    replace ^@ (^ is a special character that means "beginning of the line", so you have to put a \ in front of it to say you want the actual ^ character and not just the beginning of line) with a space

    >> g
    repeat the 'replace' globally - every time you find ^@, instead of just once

    >> > filename.dat
    direct the output of this command into the file 'filename.dat'

    Basically, what this command does is take a file and replaces all the occurences of ^@ (which is some sort of special character or command like a page break - sorry I couldn't find exactly what it was) with a space.
    LVL 2

    Author Comment

    Thanx a lot JohnK813...but I would really appreciate it if any one could help me figure out what exactly ^@ is
    LVL 14

    Expert Comment

    Aha, found it.

    ^@ is the NULL (or NUL) character.  So, here you're replacing NULLs with spaces.
    LVL 51

    Expert Comment

    >  s/\^@/ /g’

    replace any occurance of the string literal ^@ by a single space
    LVL 2

    Author Comment

    Thnk you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
    Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now