Posts

Showing posts with the label line

To get a random available port in your *nix-based machine

For example, If I want to get a random port from the 3000-3999 port pool, I would run the following command in the terminal: comm -23 <(seq 3000 3999 | sort) <(ss -tan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1

Mass resize photos in Linux with ffmpeg

To resize multiple photos at once, you can run this command line: + Resize To 1/10 its original size: $ for filename in /path/to/*.jpg; do ffmpeg -i "$filename" -y -vf scale=iw*.1:ih*.1 "$filename";done with: iw: input width ih: input height + Keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1: $ for filename in /path/to/*.jpg; do ffmpeg -i "$filename" -y -vf scale=250:-1 "$filename";done