Resizing all the images in a directory

The one-liner

I can’t recall this one liner, so here is how to resize all .jpg files in a directory, and store the result in the small directory:

mkdir -p small
for f in *.jpg; do convert -resize 25% $f small/$f; done;

The thing is, I can’t make a blog post everytime I need to remember a command

Cheatsheets ?

Actually years ago I made a list of all those weird commands I can’t quite remember completely (I’m looking at you, tar), but I’ve even forgotten about that:

Enter tldr

Another option when you know the command is to use tldr. I use tealdeer, which is a very fast rust client. It provides easy snippets right in the shell:

$ tldr seq

  Output a sequence of numbers to stdout.
  More information: <>.

  Sequence from 1 to 10:

      seq 10

  Every 3rd number from 5 to 20:

      seq 5 3 20

  Separate the output with a space instead of a newline:

      seq -s " " 5 3 20

  Format output width to a minimum of 4 digits padding with zeros as necessary:

      seq -f "%04g" 5 3 20

$ tldr for

  Shell loop over parameters.
  More information: <>.

  Perform a command with different arguments:

      for argument in 1 2 3; do command $argument; done

  Perform a command in every directory:

      for d in *; do (cd $d; command); done

See a typo ? You can suggest a modification on Github.