opengeodata.de

Best of Bash 5

2017-06-29

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:

curl ipinfo.io
curl ipinfo.io/ip 
    -- display only IP
curl ipinfo.io/country
    -- 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