I am new to unix...
How to get all the saturdays of a specific year?
for a specific month, i tried as below..
cal 02 2006 | awk '{print $7}'
but it is not giving all saturdays....
can anyone help me with this?
Thanks in advance,
Sumi
I am new to unix...
How to get all the saturdays of a specific year?
for a specific month, i tried as below..
cal 02 2006 | awk '{print $7}'
but it is not giving all saturdays....
can anyone help me with this?
Thanks in advance,
Sumi
Hi
Try the following command
cal 01 2006 | tr -s " " | sed -e '1,2d' | awk -F" " '{print $1}'
use the following in awk
$1 - For Sundays
$2 - For Mondays
$3 - For Tuesdays
and so on
Hope this helps
Regards
Bobby
i tried the command u sent...for this command,
cal 02 2006 | tr -s " " | sed -e '1,2d' | awk -F" " '{print $7}'
output should be:
4
11
18
25
but the output i am getting for the above command:
11
18
25
Read the date arithmetic article in our faq section. My datecalc script can do stuff like this:
#! /usr/bin/ksh
desiredday=$1
year=$2
(( cday = $(datecalc -j $year 1 1) + (($desiredday - $(datecalc -d $year 1 1) + 7)%7) ))
(( limit = $(datecalc -j $year 12 31) ))
while ((cday<limit)) ; do
datecalc -j $cday
((cday=cday+7))
done
exit 0
The first argument is the day of the week (0 - 6) and the second argument is the year.
./script 6 2006 will give you all saturdays for the current year.
i am using datecalc function....after subtracting 6 from dt1, i am getting
2006 1 15
dt1=2006 01 27
datecalc -a $dt1 - 6
but i want the output as
2006 01 15
i searched the forum... if i get the "day" individually and perform operation, i can use typedef. but i am using the full date and subtracting 6 from it. how to get the desired output as above?
typeset -Z2 month day
datecalc -a $dt1 - 6 | read year month day
echo $year $month $day
I have one text file which has many date fields.
Date field is in "mm/dd/yyyy" format.
I want to replace every yyyy to yy format.
If i have one year value namely 2005, i can replace as
s/2005/05/g
Since i have many values, how to generalise the the above replacement ?
Through script, i need to grep and replace.
Thanks in advance.
echo '12/05/2006' | sed 's#\([0-9][0-9]*\)/\([0-9][0-9]*\)/[0-9][0-9]\([0-9][0-9]\)#\1/\2/\3#g'
I am trying to run a job at the end of every month thru cronjob. Could you please let me know how to do it. First I tried to find the end of every month thru cal command. I have trouble. Your help is appreciated.
Pls define 'end of every month'.
Last day?
58 23 * * *[ `date +%d` -eq `echo \`cal\` | awk '{print $NF}'` ] && myJob.sh