My favourite commandline tools

Written by Super User. Posted in Uncategorised

This list will grow constantly!

A) Collate pdf files to a single file with ghostscript:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf *.pdf

B) Check wheather a file exists

if [ ! -f /tmp/foo.txt ]
    echo "File not found!"

C) make a mp4 movie from png files (works also with ffmpeg)

avconv -r 10 -start_number 8 -i filename_%d.png -b:v 1000k test.mp4

D) Keep every 100 th line of a file

awk 'NR == 1 || NR % 100 == 0' FILE

E) Convert a grepped column into a comma-separated list

grep " GREPSTRING " conf.gro  |awk  '{print $COLUMNNUMBER}' |  xargs | sed -e 's/ /,/g'

F) reinstall a linux kernel

dpkg -l | grep linux-image-.*-generic | sort -k3 | tail -n1 | awk '{system ("sudo apt-get install --reinstall " $2)}'