Closed szopin closed 2 years ago
Couple of sed replacements that should work: Remove lines starting with !
sed '/^!/d' -i test
Remove lines starting with #
sed '/^#/d' -i test
remove leading space
sed "s/^[ \t]*//" -i test
lines with no dot
sed '/./!d' -i test
Remove lines with anything that isn't letters, numbers, hyphens and dots and space and underscore
sed '/[^[:alnum:]_.\ -]/d' -i test
Remove lines that don't start with a letter or number
sed '/^[[:alnum:]]/!d' -i test
I ended up doing just: sed '/[^[:alnum:]\t\:_.\ -.]/d' -i hosts (added tabs and colon so the first few lines with '::1' would pass) on the resulting file to clean it up, thanks!
update: hosty no longer uses the inline parameter
gawk on SailfishOS does not accept inplace parameter(both awk and gawk report 3.1.5 (probably symlinked), from a quick search seems this is also the case in centos), script still works, but probably few extra hashed lines remain in the resulting hosts file