It's that easy!
I came across this while trying to print all pdf files in a directory. To do this, the simple bash script you need is:
#!/bin/bash for file in *.pdf; do /usr/bin/lpr "$file" done
Save this into a file - I called mine print-all-pdfs.sh. Then make it executable using
chmod +x print-all-pdfs.sh
Copy it to the directory you want to run it in, then execute with
For an additional challenge, can anyone adapt the above script to print all .pdfs from directories recursively? Answers in the comments below!
[References] Bash script adapted from a LinuxForums post.