Skip to content

Instantly share code, notes, and snippets.

@merovingian
Created September 30, 2015 20:05
Show Gist options
  • Save merovingian/67cbd782c8c64267084a to your computer and use it in GitHub Desktop.
Save merovingian/67cbd782c8c64267084a to your computer and use it in GitHub Desktop.
Clear Linux print queue Bash script, invoke the script with your printer on the commandline.
#! /bin/bash
# This script can be used to easily clear a print queue
# Specify your printer as the first argument
E_NO_ARGS=65
if [ $# -eq 0 ] # You must specify a printer as argument.
then
echo "Please invoke this script with one or more command-line arguments."
exit $E_NO_ARGS
fi
for i in $(lpstat -P $1 | sed 's/'$1-'//' | awk ' { print $1} ')
do lprm -P $1 $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment