November 21, 2024, 10:40:59 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: bash shell programming with functions  (Read 6517 times)

Offline universal

  • New Member
  • Posts: 2
bash shell programming with functions
« on: June 22, 2009, 03:16:07 PM »
I'm trying to write a function that will take a date in a certain format as an argument. (Say 2/13/87) Then using if then statements if the argument date is formatted correctly(2/13/87) note it can be any date,  then the date will show formatted a different way (Say 1987-2-13) if no date is entered then I need it to return just the current date.

Offline universal

  • New Member
  • Posts: 2
Re: bash shell programming with functions
« Reply #1 on: June 23, 2009, 09:25:11 PM »
This is a copy of what I have so far any help would be appreciated Thanks
function date2my()
{
date --date="$1" +"%m/%d/%y"
if [ "1" ]
    then
       echo "$1" +"%Y-%m-%d"
  else
       echo `date`
fi
}