[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

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
0
bsippy
Asked:
bsippy
  • 2
  • 2
1 Solution
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now