Linux shell script to reduce PDF file size

Originally published at: https://bash.cyberciti.biz/file-management/linux-shell-script-to-reduce-pdf-file-size/

Here is a handy and useful Linux and Unix shell script that reduce PDF file size using Ghostscript. No need to upload your PDF file to the shady third-party website. Just do it from the terminal. I tested it with both CentOS and Ubuntu/Debian Linux.

Just tried it and got this error:
`./shrinkpdf.sh “the next decade will be just as bad.pdf” the_next_decade_will_be_just_as_bad.pdf
Error: /undefinedfilename in (the next decade will be just as bad.pdf)
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
–dict:733/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)–
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.27: Unrecoverable error, exit code 1
`


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki