-- Leo's gemini proxy

-- Connecting to nuacht.flounder.online:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=utf-8

sed


Remove control chars

For some reason, sed wasn't matching my string variable against another text body which contained the same text. Turns out there were control characters from another encoding type at the end of the string: M-BM-.


cat $var didn't show them, but cat -A $var did. Solution:


$ sed 's/Ctrl+Shift+ua0 (which looks like)
$ sed 's/̲/̲u̲a̲0̲ (to be completed as usual)
$ sed 's/ / /g' mytext.txt

I got this answer from https://askubuntu.com/questions/357248/how-to-remove-special-m-bm-character-with-sed


Delete from start up to and including match:

sed '1,/^WHATEVER$/d'
sed "1,/$my_match/d"

Delete from match to end, including match:

sed '/TAGS/,$d'

Delete range (lines 3 to 5 here)

sed '3,5d' file.txt

Remove duplicate blank lines (but preserve at least one blank line)

'$!N; /^\(.*\)\n\1$/!P; D' file.txt


Print selected lines (line 5 only in this case)

sed -n '5,5p' file.txt

Get lines before match

sed -n '/_HEADER_/q;p' index.template

Get lines after match

sed -e '1,/_HEADER_/ d' index.template

Wrap HTML element around something

sed 's|www\.[^ ]*|<a href="&">&</a>|g' <newtext.txt >newtext.html

would wrap <a href....></a> around urls starting with www, for example.


Rename files in current dir so that spaces are removed

for f in *\ *; do mv "$f" "${f// /_}"; done

-- Response ended

-- Page fetched on Tue May 21 20:04:25 2024