The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 03-21-2008
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,721
For future reference if someone reads this:
try cal
Code:
#!/bin/ksh
printf "%d %d" $(date "+%Y %m") | read year month
let month=$month-1
if [[ $month -eq 0 ]] ; then
   let year=$year-1
   let month=12
fi
cal $month $year | tr -s '\n' ' ' | awk '{print $NF}' | read day
printf "%d/%02d/%02d\n" $year $month $day

Last edited by jim mcnamara; 03-21-2008 at 01:01 PM.. Reason: changed month=1 to month=12