astrovm / hosty

System-wide ad blocker for Linux/Unix/BSD/Mac
http://4st.li/hosty/
MIT License
130 stars 8 forks source link

[SFOS] gawk does not accept '-i inplace' #33

Closed szopin closed 2 years ago

szopin commented 2 years ago

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

szopin commented 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!

astrovm commented 2 years ago

https://github.com/astrolince/hosty/commit/beaa6ca58409d907c7f6979192c791d7f783cc04

astrovm commented 2 years ago

update: hosty no longer uses the inline parameter