Sponsored Content
Top Forums Shell Programming and Scripting how can i find the third friday of each month? Post 302119557 by Shell_Life on Wednesday 30th of May 2007 04:59:29 PM
Old 05-30-2007
Leslie,
See if this works for you:
Code:
typeset -i mMth=1
mYear='2007'
while [ ${mMth} -le 12 ]
do
  m3Friday=`cal ${mMth} ${mYear} | tail +3 | cut -c16,17 | sed '/^ *$/d' | sed -n '3p'`
  echo "Third Friday of "${mMth}"/"${mYear}" = "${m3Friday}
  mMth=${mMth}+1
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all files by month

Hi, I am trying to do achieving of files by months. find /test -name \*.* -mtime +30 will give me the result of all modified files after 30 days. But lets say i want to list all files that is modified in last months... what is the command to do it? Thanks! (13 Replies)
Discussion started by: maldini
13 Replies

2. Shell Programming and Scripting

Need help, Every friday in a month

I am trying to write a script that shows every Friday in a month. I used cal $1 $2 | grep -v "^$" | awk '{print $6}' It doesn't work for the frist week of Friday because calendar command output has some spaces in the first line and awk '{print $6}' doesn't work. Anybody help me with this... (3 Replies)
Discussion started by: LAY
3 Replies

3. UNIX for Dummies Questions & Answers

find out month from a date

I would like to find out the month from a given date, how is it possible. (5 Replies)
Discussion started by: rudoraj
5 Replies

4. Shell Programming and Scripting

Last friday of every month

Hi, I need to get the date of last friday of every month. how can i achieve this ? please guide me. Thanks in advance (3 Replies)
Discussion started by: apsprabhu
3 Replies

5. Shell Programming and Scripting

cron job to run on second to last friday each month

I needed a cron job to run on the second to last friday of every month. Our servers are running HP-UX, and the HP-UX date command is pretty basic and does not have all of the fancy options that Linux date command does, and it does not have the ability at all to return future dates. So I had to... (0 Replies)
Discussion started by: lupin..the..3rd
0 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Cron - job to run every 3rd Friday of the month only

Hi Expert Please help me to set a cron job schedule, Ihave a job that run every 3rd Friday of the month at 1030am. I tried to set up like this, but the job still runs every friday at 1030am. I want the job to run every 3rd Friday of the month at 1030am only 30 10 15,16,17,18,19,20,21... (2 Replies)
Discussion started by: kaibiganmi
2 Replies

7. Red Hat

How to find/display out last Friday's date of the month?

Hello, Can you please help me find/display out last Friday's date of the month using command in Unix/Linux (3 Replies)
Discussion started by: sunnysthakur
3 Replies

8. UNIX for Advanced & Expert Users

How to find last two files for a month?

Hi All, I need to find last two files for the month. lets say there are following files in directory -rwxr-xr-x 1 user userg 1596 Mar 19 15:43 c.txt -rwxr-xr-x 1 user userg 1596 Mar 21 15:43 d.txt -rwxr-xr-x 1 user userg 1596 Mar 22 15:43 f.txt -rwxr-xr-x 1... (14 Replies)
Discussion started by: Makarand Dodmis
14 Replies

9. Shell Programming and Scripting

Find one month before date

Hi, I want two dates one will be the current date and the other one will be just one month before. Say if current month is 11/4/2014 then the other date should be 11/3/2014. #!/bin/ksh currentDtae=`date` oneMonthBefore= ? I dont know how to do it. Went through some of the related threads... (15 Replies)
Discussion started by: Sharma331
15 Replies

10. Linux

Bash Display First Friday of the next month

Hello, I need to find the date of next first Friday of the month and set as a variable in a bash script ie - FIRSTFRIDAY=$(date -dfirst-friday +%d) I know date -dfirst-friday doesn't work, but unsure if I can use this / cal + awk or something else to find the right date of the... (7 Replies)
Discussion started by: summerdays
7 Replies
0intro 0intro intro 0intro 2a 2a 6a 2a 8a 2a ka 2a va 2a xa 2a 2c
2c 6c 2c 8c 2c kc 2c vc 2c xc 2c 2l 2l 6l 2l 8l 2l kl 2l vl 2l xl
2l 81/2 81/2 label 81/2 window 81/2 wloc 81/2 acid acid acme acme
awd acme win acme 8al alef alef alef kal alef val alef ar ar  art
art  art2pic art ascii ascii unicode ascii awk awk basename base-
name bc bc bind bind mount bind unmount bind  bundle  bundle  c++
c++ c++/2c c++ c++/2l c++ c++/8c c++ c++/8l c++ c++/kc c++ c++/kl
c++ c++/vc c++ c++/vl c++ cal cal calendar calendar cat cat  read
cat  char  char  rschar char 1/2char char chgrp chgrp chmod chmod
cmp cmp comm comm con con cu con rx con telnet con  xmr  con  xms
con cp cp mv cp cpp cpp cpu cpu date date db db dc dc dd dd dela-
tex deroff deroff deroff diff diff doctype  doctype  du  du  echo
echo  ed  ed emacs emacs eqn eqn factor factor primes factor file
file fmt fmt fone fone fortune fortune	freq  freq  4s	games  5s
games  ana  games  catclock games clock games festoon games fire-
works games fsim games games games life games mandel games  plumb
games  smiley games swar games grap grap graph graph grep grep gs
gs hoc hoc hp hp join join broke kill kill kill ktrans ktrans lex
lex  look  look lp lp lc ls ls ls aliasmail mail edmail mail mail
mail seemail mail sendmail mail smtp mail smtpd mail to mail vis-
mon  mail  vwhois mail lookman man man man mc mc membername mk mk
mk mkdir mkdir mothra mothra netstat netstat news news nm nm p	p
page  page  netkey  passwd passwd passwd pcc pcc pic pic tpic pic
plot plot ppp ppp pppclient ppp pppserver ppp pr  pr  kprof  prof
prof  prof proof proof ps ps psu ps pbd pwd pwd pwd cd rc eval rc
exec rc exit rc flag rc rc rc rfork rc shift rc wait rc whatis rc
~  rc  rm rm B sam sam sam sam.save sam sed sed seq seq size size
sleep sleep sort sort spell spell sprog  spell	spin  spin  split
split start stop stop stop strings strings strip strip md5sum sum
sum sum syscall syscall tail  tail  32vfs  tapefs  cpiofs  tapefs
tapefs	tapefs tapfs tapefs tarfs tapefs tpfs tapefs v10fs tapefs
v6fs tapefs tar tar tbl tbl tcs tcs tee tee iwhois  tel  tel  tel
test test bibtex tex dvips tex dviselect tex latex tex mf tex tex
tex time time touch touch tr tr nroff  troff  troff  troff  tweak
tweak twig twig uniq uniq units units ki vi vi vi xi vi wc wc who
who whois who xd xd yacc yacc yesterday yesterday
All times are GMT -4. The time now is 11:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy