Using sed to match regex -
i don't know sed, nor regex. want replace every line contains tabs string '0'. there lines in file contain '\n'.
basically want use regular expression ^\h+$ , replace matches 0.
i tried:
sed -i 's/^\h+$/0/' file.txt
but doesn't work
you can use:
sed -i.bak -e 's/^[[:blank:]]+$/0/' file
posix character class [[:blank:]]
matches space or tab same \h
in pcre.
-i.bak
keep original file in file.bak
, in case want restore.
Comments
Post a Comment