Linux, Unix, /etc/$ To set up this Linux system, do I really have to type long,
cryptic, frequently inconsistent and undocumented commands with
occasional long strings of hex digits?
# Yeah. You got a problem with that?
|
Sponsored links (requires javascript):
![]()
#!/bin/sh
#if user didn't give arguments, put >< around today's date
case $# in
0) eval `date +d=%d`
case $d in
01) d=1;;
02) d=2;;
03) d=3;;
04) d=4;;
05) d=5;;
06) d=6;;
07) d=7;;
08) d=8;;
09) d=9;;
esac
/usr/bin/cal |
sed -e 's/^/ /' -e "s/^$d />$d</" -e "s/ $d$/>$d</" -e "s/ $d />$d</"
;;
*) case $# in
0) set `date`; m=$2; y=$6 ;; # no args: use today
1) m=$1; set `date`; y=$6 ;; # 1 arg: use this year
*) m=$1; y=$2 ;; # 2 args: month and year
esac
case $m in
jan*|Jan*) m=1 ;;
feb*|Feb*) m=2 ;;
mar*|Mar*) m=3 ;;
apr*|Apr*) m=4 ;;
may*|May*) m=5 ;;
jun*|Jun*) m=6 ;;
jul*|Jul*) m=7 ;;
aug*|Aug*) m=8 ;;
sep*|Sep*) m=9 ;;
oct*|Oct*) m=10 ;;
nov*|Nov*) m=11 ;;
dec*|Dec*) m=12 ;;
[1-9]|10|11|12) ;; # numeric month
*) y=$m; m="" ;; # plain year
esac
/usr/bin/cal $m $y
;;
esac
cal $(date +'%b %Y' —date '1 month ago')
cal
cal $(date +'%b %Y' —date '1 month')
#!/usr/bin/awk -f
# cf Knuth, p. 156
{
# 1. Golden number
g = ($1 % 19) + 1;
# 2. Century
c = int($1 / 100) + 1;
# 3. Corrections
# the number of years in which the leap year was dropped in order
# to keep step with the sun e.g. 1900
x = int((3 * c) / 4) - 12;
# synchronise Easter with the moon's orbit
z = int(((8 * c) + 5) / 25) - 5;
# 4. Find Sunday
d = int((5 * $1) / 4) - x - 10;
# 5. Epact (specifies when a full moon occurs)
e = (((11 * g) + 20 + z - x)) % 30;
if ((e == 25 && g > 11) || (e == 24)) {
e = e + 1;
}
# 6. Find full moon. Easter is supposedly the "first Sunday
# following the first full moon which occurs on or after 21st
# March". Actually, peturbations in the moon's orbit make this
# not strictly true, but we are concerned here with the "calendar
# moon" rather than the actual moon. The Nth of March is a
# calendar full moon.
n = 44 - e;
if (n < 21) {
n = n + 30;
}
# 7. Advance to Sunday
n = n + 7 - ((d + n) % 7);
# 8. Get month
if (n > 31) {
n = n - 31;
printf "%d April\n", n;
}
else {
printf "%d March\n", n;
}
}
#!/bin/sh
set `date +'%A %d %B %Y'`
day=$2
case $day in
01) day=1;;
02) day=2;;
03) day=3;;
04) day=4;;
05) day=5;;
06) day=6;;
07) day=7;;
08) day=8;;
09) day=9;;
esac
case $day in
1?) day=$day"th";;
*1) day=$day"st";;
*2) day=$day"nd";;
*3) day=$day"rd";;
*) day=$day"th";;
esac
echo $1 $day $3 $4
#!/bin/sh
set `date +'%A %d %B %Y'`
day=$2
case $day in
01) day=1;;
02) day=2;;
03) day=3;;
04) day=4;;
05) day=5;;
06) day=6;;
07) day=7;;
08) day=8;;
09) day=9;;
esac
#case $day in
# 1?) day=$day"th";;
# *1) day=$day"st";;
# *2) day=$day"nd";;
# *3) day=$day"rd";;
# *) day=$day"th";;
#esac
day=$day"."
dayname=$1
case $dayname in
Monday) dayname=Montag;;
Tuesday) dayname=Dienstag;;
Wednesday) dayname=Mittwoch;;
Thursday) dayname=Donnerstag;;
Friday) dayname=Freitag;;
Saturday) dayname=Samstag;;
Sunday) dayname=Sontag;;
esac
echo $dayname $day $3 $4
#!/bin/sh
#planner
set `date '+%m %Y'`
month=$1
year=$2
2>&1 pcal -c $month $year | less
#!/bin/sh
#year
case $1 in
"-h")
echo "year: usage year [-f]"
echo "Use -f for full year (default from current month)"
;;
"-f")
2>&1 pcal -c -w | less
;;
*)
set `date '+%m %Y'`
month=$1
year=$2
left=`expr 12 - $month`
2>&1 pcal -c -w $month $year $left | less
;;
esac
#!/bin/sh
for i in Europe/Dublin Europe/Berlin US/Eastern US/Central US/Mountain US/Pacific
do
export TZ=$i
case $1 in
"") echo "`date` $i";;
*) echo "`date` $i" | grep $1;;
esac
done
#!/bin/sh
day=$1
month=$2
year=$3
case $year in
"") year=`date +%Y`;;
esac
case $month in
"") month=`date +%m`;;
esac
case $day in
"") 1>&2 echo "must give at least a day"; exit 2;;
esac
case $month in
Jan) month=01;;
Feb) month=02;;
Mar) month=03;;
Apr) month=04;;
May) month=05;;
Jun) month=06;;
Jul) month=07;;
Aug) month=08;;
Sep) month=09;;
Oct) month=10;;
Nov) month=11;;
Dec) month=12;;
esac
dayname=`date -d $month/$day/$year +%a`
case $dayname in
Sat|Sun) echo "$day of $month is $dayname, not a weekday"; exit 0;;
*) echo "$day of $month is $dayname, a weekday"; exit 1;;
esac
#!/bin/sh
/usr/bin/cal $1 $2 |
awk '{ lasta = a; a = $6; if (a == "") a=lasta } END { print a }'
#!/bin/sh
progname=`basename $0`
case $# in
0) 1>&2 echo "$progname: usage: dateseries number_of_days"; exit 1;;
esac
limit=$1
cvtday()
{
case $day in
01) day=1;;
02) day=2;;
03) day=3;;
04) day=4;;
05) day=5;;
06) day=6;;
07) day=7;;
08) day=8;;
09) day=9;;
esac
case $day in
1?) day=$day"th";;
*1) day=$day"st";;
*2) day=$day"nd";;
*3) day=$day"rd";;
*) day=$day"th";;
esac
}
for i in `series $limit`
do
set `date +'%A %d %B %Y' —date "$i day"`
day=$2
cvtday
today="$1 $day $3 $4"
echo $today
done
#!/bin/sh
#cuckoo-clock:
hour=$(expr `date +%H` % 12)
i=1
while :
do
if [ $i -gt $hour ]
then
exit 0
fi
wavplay $HOME/sounds/cuckoo.wav
i=$(expr $i + 1)
done
[back to Scripts index] [back to Linux, Unix, etc] [Main Site] [Weblog]
Contents licensed under the GPL