# Ensure trailing slash in variable
URL=https://example.com/
echo ${URL%/}/
# Loop array
A=(foo bar "ba z") # this
readarray -t A < <(ls -1 /) # or this
for E in "${A[@]}"; do echo E: $E; done
# Loop lines in file
while read -r L; do echo L: $L; done < file.txt
# cat EOF
cat << EOF > text.txt
Lorem
Ipsum
EOF
# Get server certificate
openssl s_client -connect google.com:443 < /dev/null 2> /dev/null | openssl x509 -noout -dates
# Verify password of private key
openssl pkey -in my.key.pem # Prompt
openssl pkey -in my.key.pem -passin 'pass:verysecret' -noout && echo ok
# Get random bytes
openssl rand -hex 32
# Merge two A4 PDF files into one A4 PDF file (i.e. two A5)
pdfjam pdf.pdf pdf.pdf --nup 2x1 --landscape --paper a4paper --outfile out.pdf
# Get part of video 00:00:03 to 00:01:03 (60s)
ffmpeg -i input.mp4 -c:v libx264 -ss 00:00:03 -t 60 ouput.mp4
ffmpeg -i input.mp4 -c:v libx264 -ss 00:00:03 -to 00:01:03 ouput.mp4
# Scale video (e.g. half)
ffmpeg -i input.mp4 -filter:v 'scale=iw/2:ih/2' ouput.mp4
# Crop pillars (e.g. 16:9 to 4:3)
ffmpeg -i input.mp4 -filter:v 'crop=iw/(4/3):ih:(iw-(iw/(4/3)))/2:0' output.mp4
# Add sound to video
ffmpeg -i input.mp4 -i input.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4
# Make video of images
ffmpeg -pattern_type glob -i 'images/*.jpg' -an output.mp4
# Extract first frame of movie
ffmpeg -i input.mp4 -frames:v 1 output.jpg
# Extract frame number 100, with selected quality (1 good, 31 bad)
ffmpeg -i input.mp4 -filter:v "select=eq(n\,100)" -qscale:v 10 output.jpg
# Try to make a video smaller in size (find original bitrate first)
ffmpeg -i input.mp4 -b 500k output.mp4
# Create a random image with a gradient and some noise
convert -size 192x192 gradient:blue-red -attenuate 2 +noise Gaussian -blur 0x2 image.png
# Resize the image
convert image.png -resize 50% image_small.png
convert image.png -resize 64x64 image_small.png