#!/bin/bash if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] then echo "Usage: $0 <num of pages> <first page> <file>" exit 1 fi NUM_OF_PAGES=$(( $1-1 )) FIRST_PAGE=$2 FILE=$3 EVEN_PAGES=$(seq $(( ${FIRST_PAGE}+1 )) 2 $((${FIRST_PAGE} + ${NUM_OF_PAGES}))) ODD_PAGES=$( revv $(seq ${FIRST_PAGE} 2 $(( ${FIRST_PAGE} + ${NUM_OF_PAGES} )) ) ) EVEN_PAGES=$(echo $EVEN_PAGES | tr -s '\n' ' ') if [ "$4" == "-d" ] then echo $NUM_OF_PAGES echo $FIRST_PAGE echo $FILE echo "ODD $ODD_PAGES" echo "EVEN $EVEN_PAGES" exit -1 fi for PAGE in $EVEN_PAGES do lp -P $PAGE $FILE sleep 0.5 done echo echo "*******************************************" echo "*** ***" echo "*** WAIT UNTIL THE PRINT FINISHES ***" echo "*** THEN SWAP THE PAPER AND PRESS ENTER ***" echo "*** ***" echo -n "*******************************************" read echo for PAGE in $ODD_PAGES do lp -P $PAGE $FILE sleep 0.5 donebasicly this help you to save paper...
it print the EVEN pages in reverse order
then you take this pages and put it all the
printer again with the printed side up
and the up side of text in direction of printer
like this:
PRINTER
text /\
and press enter or any other key...
in the end you have a two side print and the
pages in order (i hope so)
(( i don't fully test cuz my printer eat papper ¬¬ ))
oh ... i almost forgot
this Bash script depends of a litle C program to revert the order of numbers
get from seq, is the revv in 13th line
here is ...
/* * This program reverse the order of its arguments * e.g AB CD EF become EF CD AB */ #include <stdio.h> int main (int argc, char **argv) { argc--; for (; argc > 0; argc--) printf("%s ", argv[argc]); return 0; }
cheers!
Nenhum comentário:
Postar um comentário