==> starwars <== #!/bin/sh # usage: starwars # # Imperial March on /dev/speaker. echo 'O0 G G G L8 D#. L16 A# L4 G L8 D#. L16 A# L2 G' >/dev/speaker ==> countwords <== #!/bin/sh # usage: countwords [file ...] # # Count UTF-8 words from files or stdin. perl -n -mutf8 -M'open ":std", ":encoding(UTF-8)"' \ -e 'print "$_\n" for split(/\P{L}+/, lc $_);' -- "$@" | tr -s \\n | sort | uniq -c | sort -nr ==> carr <== #!/bin/sh # usage: carr [file ...] # # Represent files or stdin as a C array. od -v -t x1 -- "$@" | awk ' BEGIN {print "{"} NF > 1 { printf "\t" for (i = 2; i <= NF; i++) printf "0x%s,", $i print "" } END {print "};"} ' ==> fat32_format <== To format an entire disk as FAT32 under OpenBSD, type: # fdisk -iy sdX # fdisk -e sdX > edit 3 Partition id ('0' to disable) [01 - FF]: [A6] (? for help) 0C Do you wish to edit in CHS mode? [n] Partition offset [0 - $HIGH_NUMBER]: [64] Partition size [1 - $HIGH_NUMBER]: [$HIGH_NUMBER] > w > q # newfs_msdos -F 32 sdXi 0xOC is Win95 FAT32L. ==> lessout <<== In order for less to print the current screenfull to stdout and exit on a keypress ('Q' in this case), first create the following script somewhere in your $PATH: #!/bin/sh col -b # or ul if you want formatting kill $(ps -o ppid -p $PPID | tail -1) Add the following to ~/.lesskey: Q pipe .lessout\r (Where lessout is the name of the above script.) And run $ lesskey Explanation: The period in pipe .myscript\r means current screenful. Unfortunately, less doesn't allow you to run multiple commands with one keybinding, so we want to kill less (I am so glad this text is unlikely to be of interest to lawyers) from the script. The script is run via system("script"), which effectively translates to /bin/sh -c 'script', or /bin/sh -c '/bin/sh /path/to/script'. So, $$ is PID of the shell actually running the script, $PPID is the shell invoked by system(), and the parent that shell is the invoking less.