Reputation: 1985
I have a file that's generated as an output to an SQL query. I need to replace the nulls in the file with blanks, so something like
sed -e"s/null//g"
would work.
However there's a valid string of the form 'null/' (with a trailing forward slash) and that should not be replaced. Is there a way to replace only 'null' values while leaving 'null/' intact?
Upvotes: 0
Views: 199
Reputation: 195029
The sed one-liner:
sed 's#null\([^/]\|$\)#\1#g' file
should work for your requirement.
It searches pattern: null and followed by a non-slash char (or EOL)
,
replace with the followed non-slash char
.
Thus, null/
won't be touched.
Upvotes: 2