U1FFF: Unix 1-liner Five Fridays Funfair 2020
===================================================
Acronybanner
==============
$ banner `echo "My Personal Acronybanner " | sed -E 's/([1-9a-zA-z])[-a-zA-Z]+ /\1/g'`
Explanation: Make a banner acronym from a string given as input.
Comment: Slightly modified to create the logo of the U1FFF. Put a space
after the last word ;)
Author: Anonymous Unix Wizard
snl
=====
$ cat file.txt | sed "=" | sed -n "N;s/\n/ /;p;d;"
Explanation: number lines in a file when you don't have nl(1)
Comment: the stuff after "\n/" is actually a TAB.
Author: Anonymous Unix Wizard
One-line linux container
==========================
# mkdir /ns; tar -c /lib /bin |tar -C /ns -x|ip netns add ct;ip netns exec ct unshare -fpium env -i chroot /ns /bin/echo why?
Explanation: Who needs docker ? One-line linux container (as root)
Author: z3bra
Funfair random game
=====================
$ COINS=3; tr -cd WIN < /dev/urandom | fold -w 3 | head -n $COINS | grep WIN || echo Sorry!
Explanation: Try your luck at the fun fair random game ! One coin,
one try. If it prints "win", then... Well you win !
Author: z3bra
Proper kill
=============
$ kill -SEGV $pid
Comment: I am tired of people using `kill -9` for no reason, so I
teach them the one true way
Author: z3bra
World's simplest Gopher client
================================
$ read r; cat /var/gopher${r##../}
Explanation: To be used from an inetd server. Put the above in a script in /usr/local/bin/gphd
using the following line:
gopher stream tcp nowait nobody /usr/local/bin/gphd
Author: z3bra
sfmt
======
$ sed ':c;$b;/^[ \t]*$/b;/^.\{,69\}$/{h;s///;N;/^\n[ \t]*$/{;H;g;s/\n\n*/\n/;bt;};s/^\n[ \t]*//;s/[ \t][ \t]*$//;H;g;s/\n\n*/ /g;s/[ \t][ \t]*$//;bc;};:t;/^.\{,70\}$/!{s/^\(.\{1,70\}\)\([ \t][ \t]*\)\(.*\)$/\1\n\3/;s/[ \t]*$//;P;D;}'
Explanation: A simplified fmt(1) that wraps lines to 70 spaces and handles
paragraphs
Comment: yes, it's longer than 128 bytes, but I am sure there exists at
least one screen where it fits in exactly one line....
Author: KatolaZ
random mpd album
==================
$ mpc findadd album "$(mpc list album | sort -R | head -1)"
Explanation: Add a random album to the mpd queue.
Author: adc
timestamp
===========
$ while read -r; do printf '%s %s\n' "$(date '+$H:$M:$S')" "$REPLY"; done
Explanation: Add a timestamp to every line in stdin.
Author: adc
dict client
=============
$ dict(){ echo "define ${2:-*} $1" | nc dict.org 2628 | less ; }
$ dict unix jargon
Author: anthk
stac
======
$ sed -nE '1{h;b;};$!{G;x;};${G;p;}' file.txt
Explanation: simple tac (print a file from the last line upwards)
Author: Anonymous Unix Wizard
Youtube Browser in ELinks
===========================
$ ytb (){ [ "${1##*[!0-9]*}" ] && $YTBD --playlist-end $1 "$2"|$YTBE|$YTBS
|| $YTBD "$1"|$YTBE|$YTBS;elinks $YTBF;rm -f $YTBF; }
Usage: ytb [MAX RESULTS] URL
Comment: In ELinks: "<" ">" to change tabs/results, "W" to wrap text.
Enable option "document.plain.display_links" in ELinks config. for
download/viewable video/image URLs. "less" could be used instead of
ELinks, with navigation between results using the ":n" and ":p"
commands. Some X terminal programs can detect URLs by themselves.
Author: The Free Thinker
Gophernicus trick
===================
$ sed '2i # \x00' script.sh > script
Explanation: Inserts a null byte at the second line to trick
Gophernicus into thinking it's a binary file. This still won't work if
a text extension is used such as ".sh" or ".txt".
Author: The Free Thinker
Phlog Index Gophermap
=======================
$ cp phloghead gophermap; for i in `ls -r *.txt`; do echo -e "0$i\t"; \
done >> gophermap
Explanation: Make a gophermap index for a series of phlogs
Comment: Only works if you begin all of your phlog post filenames with a
Y-M-D formatted date, like me.
Example:
$ echo "Welcome to the phlogging a dead horse phlog" > phloghead
$ echo "First post - not much to say so far..." > 2020-10-23First_Post.txt
$ cp phloghead gophermap; for i in `ls -r *.txt`; do echo -e "0$i\t"; \
done >> gophermap
Author: The Free Thinker
monitoring suite
==================
$ while read line; do $line >/dev/null 2>&1 || logger -cs -p local0.alert -t monitor "$line" & done </etc/monitor.conf; wait
Explanation: It is a monitoring suite, that reads configuration in
this form (which can be generated or edited manually)
Comment: more details on format and functioning at:
gopher://katolaz.net/0/U1FFF_2020/josuah.txt
Author: Josuah
Veronica search
=================
$ veronica() {echo "/v2/vs?sq=$(echo "$*"|tr ' ' '+')" |nc gopher.floodgap.com 70|grep "^igoph"|cut -f1|sed "s/^i//"}
Explanation: Simply type 'veronica <search query>' and get returned up
to 30 matches from Veronica 2 to satisfy your Gopher
search itch!
Author: xt