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

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -