Sunday, December 1, 2019

To Convert a Load of Document Files into Plain Text (In Order to Diff Them)

for i in * ; 
do 
  echo "$i" ;
  libreoffice --headless --convert-to txt:Text "$i" ; 
done

Saturday, July 6, 2019

To Play a Random Sound File in a Tree

mplayer "$(find . -name "*.3gp" | shuf -n1)"

To type Latin Macrons āēīōū

in X generally, you need to use the Compose key, most keyboards don't have one, so Compose is usually done with shift+Alt Gr,

Compose - a and Compose a - will both produce an ā

but it's more convenient to make the right Alt key (AltGr) be the compose key

to try it in a terminal
setxkbmap -option "compose:ralt"

to make it the system default:
sudo dpkg-reconfigure keyboard-configuration

you can also get it to work just in your desktop environment with e.g. in xfce, Applications/Settings/Keyboard/Layout

To play all the sound files in a tree

find . -name "*.3gp" -exec mplayer {} \;

Saturday, May 25, 2019

To Turn .midi Files Into .wav Files

for i in *.midi; do timidity -Ow -o  "${i%.midi}.wav" "$i" ; done

Thursday, March 28, 2019

Tuesday, March 19, 2019

To move the five most recent files to a subdirectory

ls -rt will show you the files most recent first.

To move the most recent five to a subdirectory:

mkdir -p recent && find -maxdepth 1 -type f -printf '%T@ %P\n' | sort -rn | cut -d' ' -f2- | head -n 5 | xargs -I{} mv {} recent

Monday, March 4, 2019

To Find the Most Recent Version of a File

Occasionally it so happens that you want to find the most recent version of thing.

Suppose that you're trying to find your most recent timesheet.

Then:

find ~ -type f -name "*timesheet*" -printf "%T@ %t %p\n" | sort -n 

does the business.

Output looks something like:

1519655146.5096155360 Mon Feb 26 14:25:46.5096155360 2018 /home/john/data/.~/timesheet.py.~86~
1519925511.1565392570 Thu Mar  1 17:31:51.1565392570 2018 /home/john/data/.~/timesheet.py.~87~
1520000595.5182763930 Fri Mar  2 14:23:15.5182763930 2018 /home/john/data/timesheet.py

Where the first column is a sortable version of the last modification time "%T@", and the second "%t" is the human readable form.

The last thing printed will be the most recent file in your home directory tree with timesheet in the name.

Monday, January 7, 2019

Linux Laptop Battery Level

sudo apt-get install acpi 
acpi -V

or:

upower -i `upower -e | grep 'BAT'`