User Tools

Site Tools


geek:cli

Command Line Hacks

Image metadata

This shows me the EXIF time/date of every image in a directory, useful when I'm sorting:

Needs the debian package 'exif'.

for i in *; do echo $i; exif -t 0x0132 $i  | grep Value; done;

Xargs and Find

Performing operations on multiple files using xargs and find:

Escapes the filenames and supplies, through xargs, as many parameters as possible to rm on the command line for efficency. Also an example using two or more parameters with mv.

find $HOME -iname "*.jpg" -print0 | xargs -0 rm
find $HOME -iname "*.jpg" -exec mv {} /dest/dir/ \;
find . -exec grep -Hn hello {} \;

Watch a file

Watch a file and do something to it when it changes:

In this case, watch the file 'example.php' and when it changes, show the output in another terminal.

fswatch -0 example.php | xargs -0 -n 1 -I {} php {}

Certificate Expiry

Check the expiry date on a SSL certificate PEM file:

openssl x509 -enddate -noout -in cert.pem 

Read a certificate directly from a URL:

echo | openssl s_client -showcerts -servername glasgow.social -connect glasgow.social:443 2>/dev/null | openssl x509 -inform pem -noout -text

Journalctl

I'm so used to using init.d I can't keep these instructions in my head, so they're written here until I remember them.

Listing all available services



Getting logs for a particular service



geek/cli.txt · Last modified: 2024/05/23 11:55 by admin