A collection of useful command-line snippets and tricks for quick reference.
find
find . -type f -exec tail -n +1 {} +
- Recursively search the current directory and subdirectories for regular files, then display their contents along with each file’s path.
imagemagick
convert -resize 50% input.png output.png
- resize half an image
convert -bordercolor white -border 3 -bordercolor black -border 86 input.png output.png
- add border to an image
convert < input .png > -resize < 800x800 > -colorspace gray -ordered-dither o8x8 < output .png >
- image dithering
ffmpeg
ffmpeg -f pulse -i <source monitor> -ac 2 -ar 48000 -c:a libmp3lame -b:a 320k output.mp3
# to get source monitor, use: pactl list short sources
- Record audio from source input.
ffmpeg -ss < starting point > -i < input > -t < how long > -vcodec copy -acodec copy < output >
# e.g., ffmpeg -ss 00:00:30 -i input.mp4 -t 00:00:05 -vcodec copy -acodec copy output.mp4
- Cut specific timeline from video.
vim files.txt
file 'vid_1.mp4'
file 'vid_2.mp4'
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
- Merge multiple videos.
ffmpeg -i input.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 output.mp3
ffmpeg -fflags +genpts -i input.webm -r 24 output.mp4
- Convert mp4-> mp3, webm-> mp4
ffmpeg -i input.mp3 -filter:a "volume=0.2" -c:a pcm_f32le output.wav
- Decrease music volume.
ffmpeg -i input.mp4 -i input.wav -map 0:v -map 1:a -c:v copy -shortest output.mp4
- Add music for a video.
other
didder --palette 'black white' -i input.png -o output.png bayer 16x16
- Image dithering.
rsync ~/.bashrc backup/.bashrc
- sync two files.
pdftk < input > cat < start >-< end > output < output >
- Get specific page(s) from pdf.
