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.

openssl x509 -enddate -noout -in cert.pem 

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

systemctl list-unit-files --all | grep enabled

Getting logs for a particular service

journalctl -u sshd
geek/cli.txt · Last modified: 2019/12/28 19:15 by neil