P RAJESH
P RAJESH

Reputation: 23

Format output of the test file using sed command

tried this to ( sed 's/\^/||\'\^'\||/g' best4.txt>best5.txt ) is not woking need to substitute ^ to '^'.

if a text file contain below content (best4.txt).

SELECT FED1||^||FED2||^||FED3 FROM TEMP; 

output of the file should be (best5.txt).

SELECT FED1||'^'||FED2||'^'||FED3 FROM TEMP; 

Upvotes: 0

Views: 154

Answers (1)

Bogdan Stoica
Bogdan Stoica

Reputation: 4539

Try with this:

sed "s|\^|'^'|g" best4.txt>best5.txt

With sed, the ^ sign, just like in vim, means beginning of a line. In your case you want the ^ sign to be interpreted as the sign and not the beginning of a line, so since ^ is a special char you have to escape it and in sed/vim you do that adding a backslash (\) in front of it.

If you want to directly replace in the same file you can use sed -i

Upvotes: 1

Related Questions