bash - Replace NULL string pattern with blank -


i have pipe delimiter file in need replace null string blank. file huge around 9 gb , contain 2 million records , has 150 columns delimited pipe.

pqr|null|null|null abc|abc null xyz|xyz null|null 

desired output

pqr|||null abc|abc null xyz|xyz null| 

using perl can use lookaheads this:

perl -pe 's/(?<=\|)null(?=\||$)//g' file 

output:

pqr|||null abc|abc null xyz|xyz null| 

if don't have perl sed should work:

sed 's/|null|/||/g; s/|null\(|\|$\)/|\1/g' file 

output:

pqr|||null abc|abc null xyz|xyz null| 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

post - imageshack API cURL -