Best of bash 1


As a mean to reflect and preserve certain useful commands, I’ll start this little series. Here we go:

mogrify -resize 50x50% -quality 90 -format jpg *.JPG

Take all JPG files in one folder and reduce their size by 50%.

sudo add-apt-repository ppa:fossfreedom/byzanz
sudo apt-get update && sudo apt-get install byzanz
byzanz-record -c -d 120 --delay=3 record.gif
ffmpeg -i record.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)_2:trunc(ih/2)_2" video.mp4

Get the byzanz-record tool which will create a relatively small GIF of you using your screen to quickly solve a problem and show this to someone else. ffmpeg will convert it to a video in case it is neccessary.

for i in {01..12}; do gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dFirstPage=$i -dLastPage=$i -sOUTPUTFILE=output_$i.pdf certificates.pdf; done

Convert a 12-paged PDF file to 12 single-paged files.

nmap -p 22 --open -sV > sshservers.txt

Scan a local network for ssh-enabled devices; useful for finding your Raspberry Pi in a semi-public WLAN.