User Tools

Site Tools


geek:cli

This is an old revision of the document!


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

openssl x509 -enddate -noout -in cert.pem 
geek/cli.1571862217.txt.gz · Last modified: 2019/10/23 20:23 by neil