Skip to content

Instantly share code, notes, and snippets.

@huwan
Created June 22, 2014 10:37
Show Gist options
  • Save huwan/43e58f88938daa0098f0 to your computer and use it in GitHub Desktop.
Save huwan/43e58f88938daa0098f0 to your computer and use it in GitHub Desktop.
打印日历笔记本的今明两天(2014年)
#! /bin/bash
#yesterday=`date -d '-1 day' +%Y%m%d`
today=`date +%Y%m%d`
pagebegin=`date -f <(seq 20140101 $today) +%F 2>/dev/null |wc -l`
pageend=$(($pagebegin+1))
filename="daydayup.pdf"
username="printer"
if [ ! -f hist.ory ]; then
echo "-1" > hist.ory
fi
n=`cat hist.ory`
if [ $n -eq $pagebegin -o $n -eq $(($pagebegin-1)) ]; then
echo "Already print these pages!"
else
echo "lp -U $username -P $pagebegin-$pageend -o sides=two-sided-long-edge $filename"
lp -U $username -P $pagebegin-$pageend -o sides=two-sided-long-edge $filename
echo "$pagebegin" > hist.ory
fi
@huwan
Copy link
Author

huwan commented Jun 22, 2014

自己会将有日历的笔记纸打印出来,当然是有需要的时候打印出当天和第二天的,而不是一次打印一年的。

  • 2014年日历笔记本 见链接:http://pan.baidu.com/s/1kT5evXl
  • 脚本先计算当天是一年中第几天,然后打印当天和第二天;
  • 会检测昨天或者今天是否已经打印,防止重复打印;
  • ubuntu 使用Windows的共享打印机,设置为默认打印机;
  • 默认双面打印以节约纸张;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment