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
Post a Comment