Best of Bash 5


A thing the great Julia Evans was using in a recent blog post: tr.

tr - translate or delete characters

cat /proc/3091/environ  | tr '\0' '\n'

-- get the environment variables from process 3091
-- the environment variables contain hidden null bytes (\0)
-- which will be replaced with a new line (\n) by tr

Another quick and easy yet very helpful tool - mogrify. It is actually a common “household remedy” for a great deal of tasks in linux image processing, yet I wasn’t aware of this simple usage example, which will convert any .bmp in a directory to .jpg.

mogrify -format jpg *.bmp

I wrote about the IP lookup in bash some time ago but this service is imho the simplest one:

    -- display only IP
    -- display only country

A nice snippet for finding the most recently changed files in a directory (and its subdirectories):

find $1 -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head