Reputation: 12190
Using sed
how can I replace \N with NULL
How can I replace the empty space || with NULL.
|200|0||0|\N||^A|0|\N||
desired output
|200|0|NULL|0|NULL|NULL|^A|0|NULL|NULL|
Upvotes: 4
Views: 10730
Reputation: 47099
You need a slightly modified version of this. Something like this works with GNU sed:
sed ':a; s:|\(\\N\)\?|:|NULL|:g; ta'
Or more portable:
sed -e ':a' -e 's:|\(\\N\)\?|:|NULL|:g' -e 'ta'
Upvotes: 4
Reputation: 5492
<file sed 's/\\N/NULL/g' | awk -F\| '{for(i=2;i<=NF;i++){ if($i==""){ printf "|NULL"} else{ printf "|%s", $i}}; printf "|\n"}'
Upvotes: 0
Reputation: 7
sed -i 's/ /NULL/g' temp.txt
This will replace any space character with NULL
.
Upvotes: -2
Reputation: 31548
with awk
awk 'gsub("\\\\N","NULL");gsub("\\|\\|","|NULL|")' temp.txt
Upvotes: 0
Reputation: 10367
I think the command you are looking for might be called "tr". Try
tr \\n \\0
Upvotes: 1