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 -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -