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

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
LVL 2
bsippyAsked:
Who is Participating?
 
JohnK813Commented:
>> 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
edit

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

>> s
substitute

>> /\^@/ /
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.
0
 
bsippyAuthor Commented:
Thanx a lot JohnK813...but I would really appreciate it if any one could help me figure out what exactly ^@ is
0
 
JohnK813Commented:
Aha, found it.

^@ is the NULL (or NUL) character.  So, here you're replacing NULLs with spaces.
0
 
ahoffmannCommented:
>  s/\^@/ /g’

replace any occurance of the string literal ^@ by a single space
0
 
bsippyAuthor Commented:
Thnk you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.