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'`

Wednesday, May 9, 2018

Lilypond in Debian Stretch

lilypond wasn't included in stretch, but has been backported

add

deb http://ftp.debian.org/debian stretch-backports main

to /etc/apt/sources.list, and then

sudo apt update
sudo apt-get -t stretch-backports install lilypond



Friday, April 20, 2018

To install a new version of Racket on an old version of Debian

Running Debian 8 which has Racket 2.1.

Trying to work through

http://io.livecode.ch/learn/gregr/icfp2017-artifact-auas7pp

for which there is a Racket Package

2.1 is not good enough, need Racket 2.6

Check out:

https://backports.debian.org/Instructions/

$ su

# echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list

# apt update

# apt-get -t jessie-backports install racket

Now have Racket 2.7, which is good enough.

Friday, August 4, 2017

grep just highlight

https://stackoverflow.com/questions/7393906/highlight-text-similar-to-grep-but-dont-filter-out-text#7394821

Trick is to use ^ to every line with a start-of-line. Since that's unprintable it won't get highlighted.

So to list all the files with arista in the name, but highlight the objects:

find . -name "*arista*" | grep -E '^|\.o|.so'