[x] Welcome to LinuxSolved.com Linux help forums, here we are a community of Linux users helping each other. It is helpful to both ie. new linux users as well experienced one. We always have our experts to help you and ofcourse members help each other, so you can ask for help any time by Registering.: Click to Register

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Linux Forums - Linux Help,Advice & support community:LinuxSolved.com  |  Forum  |  Others  |  Miscellaneous  |  Topic: bash shell programming with functions
Welcome to LinuxCommunity

You have just arrived to a friendly linux community which is helping Linux Users from Years.. You can be its part if you have not already joined it. Registration is FREE and is gateway to unlimited help and support to all your linux related needs. If you are an GNU/Linux supporter then you have come to the right place.
Pages: [1]
  Print  
Author Topic: bash shell programming with functions  (Read 344 times)
0 Members and 1 Guest are viewing this topic.
universal
New Member

Offline Offline

Posts: 2


View Profile
« on: June 22, 2009, 11:16:07 AM »

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.
Logged
universal
New Member

Offline Offline

Posts: 2


View Profile
« Reply #1 on: June 23, 2009, 05: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
}
 
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
BASH SHELL SCRIPT Linux Development & Programming nicksthegreat 1 1559 Last post April 08, 2004, 06:02:04 AM
by sudipta_cht
How to change bash profile? Linux Installation Support hawk 1 3054 Last post August 05, 2004, 05:12:29 AM
by dragoncity99
BASH, UTF-8 and portability Linux Development & Programming Provola 0 1290 Last post October 13, 2004, 09:35:17 AM
by Provola
Efficient bash operation Miscellaneous Ujjwol 1 439 Last post May 21, 2007, 03:21:08 PM
by Ricky
-bash Forum Talk dannymessick 0 115 Last post June 15, 2010, 06:16:56 PM
by dannymessick
Search LS
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 29, 2010, 10:14:03 AM

Login with username, password and session length
Navigation
Recent Discussions
[July 24, 2010, 11:46:22 PM]

[July 24, 2010, 04:10:46 PM]

[July 23, 2010, 07:22:27 AM]

[July 23, 2010, 07:20:53 AM]

[July 23, 2010, 07:19:15 AM]

[July 23, 2010, 07:15:30 AM]

[July 23, 2010, 07:08:21 AM]

[July 19, 2010, 11:01:10 PM]

[July 19, 2010, 10:01:58 AM]

[July 19, 2010, 01:21:00 AM]
Members
Total Members: 7690
Latest: BOZZYPRINCESS
Stats
Total Posts: 9524
Total Topics: 2729
Online Today: 7
Online Ever: 128
(April 10, 2010, 10:24:17 PM)
Users Online
Users: 0
Guests: 13
Total: 13
Privacy Policy| Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Theme & TinyPortal v0.9.8 © Bloc