Skip to main content
  1. Posts/

useful command line tools for uni

This blog post is a collection of useful (linux) tools for PDFs, like slides or problem sheets at university. For every use case I give one example that should make the usage clear. Make sure to have the tools installed.

Concatenate two or more PDFs:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf 3.pdf n.pdf

Concatenate all PDFs in one folder.

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH *.pdf > /dev/null

JPEGs to pdf.

img2pdf *.jpg -o submission.pdf

Add white margin to a pdf. Negative values mean add and positive values remove margin.

pdfjam --fitpaper true --trim "-2cm 0cm -4cm 0cm" somepdf.pdf -o somepdf_margin.pdf

Download all PDFs from a website. If you are looking for an more advanced download tool that, among other sites, supports Ilias. Take a look at PFERD it is written by fellow students and a huge time saver.

wget -r -A '*.pdf' https://example.com

Collapse folder structure (e.g. created by the previous command).

find somefolder/ -type f -exec mv -t somefolder/ -i '{}' +

Remove newlines from the clipboard (e.g. when copying text from PDFs)

xclip -o | sed ':a;N;$!ba;s/-\n[a-z]//g' | sed ':a;N;$!ba;s/\n/ /g' | xclip -sel clip

To search in all notes (PDFs, plaintext, images etc.) take a look at ripgrep-all. If you want a more lightweight tool that just greps PDFs pdfgrep will do the job.

Get cheatsheets for almost any tool. Append the toolname to cheat.sh

curl cheat.sh/"gs"