This question already has an answer here:
I've got a PDF of a scanned document that's around 20MB and I need to drastically reduce the filesize to be able to email it. I've tried
gs -sDevice=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
output.pdf isn't created. Instead, I get an X Viewer for Ghostscript briefly. Where am I going wrong?