get date for all saturdays in given year


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get date for all saturdays in given year
# 1  
Old 01-10-2012
get date for all saturdays in given year

Hello Guys

I browsed through site for mentioned requirement all solutions I got in perl

I am looking for something in unix script for same

any suggestions

thanks
# 2  
Old 01-10-2012
What would you like?

I could write something in ksh perhaps based on the cal command:-

Code:
#!/bin/ksh
sat=25-26
year=2012
for month in 1 2 3 4 5 6 7 8 9 10 11 12
do
   case month in
     1) echo "Jan $year: \c" ;;
     2) echo "Feb $year: \c" ;;
     3) echo "Mar $year: \c" ;;
     4) echo "Apr $year: \c" ;;
     5) echo "May $year: \c" ;;
     6) echo "Jun $year: \c" ;;
     7) echo "Jul $year: \c" ;;
     8) echo "Aug $year: \c" ;;
     9) echo "Sep $year: \c" ;;
    10) echo "Oct $year: \c" ;;
    11) echo "Nov $year: \c" ;;
    12) echo "Dec $year: \c" ;;
   esac

   cal $month $year|egrep -v "[A-Z]"|cut -c"$sat"|while read line
   do
      echo "$line \c"
   done
   echo
done


Pretty nasty code really, but does that suffice? There are more likely better date functions available in awk.

You might need to adjust the value sat to get the right columns in the cal output. HPUX is 19-20, AIX is 25-26.




Robin
Liverpool/Blackburn
UK

Last edited by rbatte1; 01-10-2012 at 10:06 AM..
This User Gave Thanks to rbatte1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How bash treats literal date value and retrieve year, month and date?

Hi, I am trying to add few (say 3 days) to sysdate using - date -d '+ 3 days' +%y%m%d and it works as expected. But how to add few (say 3 days) to a literal date value and how bash treats a literal value as a date. Can we say just like in ORACLE TO_DATE that my given literal date value... (2 Replies)
Discussion started by: pointers1234
2 Replies

2. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

3. Shell Programming and Scripting

How to list files that are not first two files date & last file date for every month-year?

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Previous Year Date

Hi Gurus, I would like to get the date for the previous year based on the date I specify. For e.g. If I input today's date (i.e. 20130422) I need to get 20120422. We don't have GNU and use K Shell. Any help is highly appreciated. Thanks Shash (4 Replies)
Discussion started by: shash
4 Replies

5. Shell Programming and Scripting

Listing files that belong to a certain year date?

I'm trying to list files, first by size and I'm using something like this ls -l|awk '{print $5,$6,$7,$8,$9|"sort -nr"}'|more Now I'd like to just do the same listing but only for files with the year 2009 in the $8 field or even anything less than 2011. (5 Replies)
Discussion started by: NycUnxer
5 Replies

6. Shell Programming and Scripting

Derive the Year value from the date value

Hi All, I have two dates: PREVIOUS_DAY and CURRENT_DAY. I need to test the these two values years are same or not. PREVIOUS_DAY like '%y%m%d' i.e values like 111010, 111011, 111012 etc. For CURRENT_YEAR:'date +%Y' use this command. How can derive the year value from PREVIOUS_DAY and... (1 Reply)
Discussion started by: pdathu
1 Replies

7. Shell Programming and Scripting

Awk convert from day of year to date

Hello everyone, I have a file which has day of year in one of the columns (JD=substr($0,72,3)). The bellow scripts shows me the minimum and maximum values of the JD and I would like to convert the JD to date. #!/bin/gawk -f { check=substr($0,1,1) if (check == "S") { ... (6 Replies)
Discussion started by: alex2005
6 Replies

8. Shell Programming and Scripting

Help to generate date from day of the year

Hi I want to convert the day of the year(yyyyddd) to date in mmddyy format Example: input is 2005029 --------> 29th day of 2005 I have to get the output as 01292005 ---> jan 29th 2005 I've to do this in K-Shell There were threads that dealt with coverting date to day of the year but I... (3 Replies)
Discussion started by: sudhamayeev
3 Replies

9. UNIX for Dummies Questions & Answers

Date Script problem for year cross over

Hello, I'm very new to script writing - everything I have I got off the Internet. I'm pretty sure I stole this date script from this site. Anyway, the script works great until I try to obtain a date that falls into last year. I can get 'Dec 31, 2009' but nothing earlier. Below is the... (3 Replies)
Discussion started by: Colel2
3 Replies

10. Shell Programming and Scripting

Add 1 year to System date in script

Hi All, I wanted to add 1 year to the system date in my script. say export start_date=`date +%F` echo $start_date o/p of this is 2009-09-02 To this i want to add 1 year. the output i need here is 2010-09-02 can anybody help me ? Thanks in advance, Vinay (4 Replies)
Discussion started by: vinayakatj56
4 Replies
Login or Register to Ask a Question