File: birthday

package info (click to toggle)
addressbook 0.7-13
  • links: PTS
  • area: main
  • in suites: potato
  • size: 960 kB
  • ctags: 160
  • sloc: tcl: 6,002; perl: 528; ansic: 362; awk: 205; sh: 123; makefile: 95
file content (52 lines) | stat: -rwxr-xr-x 1,248 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
# 
# Birthday remember script
#
# Clemens Durka (durka@informatik.tu-muenchen.de)
#
# Please adjust the following three variables, the fields for the first
# and lastname and the field, where the birthday is stored. The field
# begins to count with 1 (not 0 as in the formatfile - sorry)
#
NAME1=1
NAME2=2
BIRTHDAYFIELD=8
#
# Please set the addressbookfile
#
ADDRESSBOOKFILE=~/pub/adr/lib/addresses.dat
#
# Please set the dateformat
#
# DD.MM.YYYY: german speaking countries 
DATEFORMAT1=`date +%d.%m`\\.
DATEFORMAT2=\\.`date +%m`\\.
#
# MM/DD/YYYY: USA 
#DATEFORMAT1=`date +%m/%d`\\/
#DATEFORMAT2=" "`date +%m`\\/
#
# DD-MM-YYYY: Great Britain 
#DATEFORMAT1=`date +%d-%m`\\-
#DATEFORMAT2=\\-`date +%m`\\-

# DD/MM/YYYY: France 
#DATEFORMAT1=`date +%d/%m`\\/
#DATEFORMAT2=\\/`date +%m`\\/
#

date +"%A, %d %B %Y"
echo

echo "Today's birthday:"
cut -f ${NAME1},${NAME2},${BIRTHDAYFIELD} -d \; ${ADDRESSBOOKFILE} | sed 's/;/ /g' | \
    grep ${DATEFORMAT1} | \
    awk '{print $3 ": ",$1,$2}' 
echo
echo "This month's birthdays:"
cut -f ${NAME1},${NAME2},${BIRTHDAYFIELD} -d \; ${ADDRESSBOOKFILE} | sed 's/;/ /g' | \
    grep ${DATEFORMAT2} | sort +2 | \
#    sed 's/ \([^ ]* *[^ ]*\)  \(.*\)/\2: \1/g'
    awk '{print $3 ":",$1,$2}'
echo