LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-21-2010, 08:17 AM   #1
Abid Malik
LQ Newbie
 
Registered: Sep 2010
Posts: 25

Rep: Reputation: -1
Question read date


Hello!

i want to know that how we can read date in format of 12/04/2010

in bash shell script

i mean , i want to read date form key board

i want that the user give input in the form of 12/04/2010 and then system varify that the entered date formate is correct or not. if it is valid , system will print echo " valid date" otherwise system will print echo "invalid date format"

Last edited by Abid Malik; 10-21-2010 at 08:44 AM.
 
Old 10-21-2010, 08:27 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Your question is a little bit ambiguous.. Do you want to simply have the user enter a date in that format (use the `read` command) or do you want them to enter a date, and have it outputted in that format?

Here's something to ponder meanwhile:
Code:
read -p "Enter the date: " datestring; echo $(date -d "${datestring}" +%D)
So, I enter a date and it formats it like you showed:
Code:
Enter the date: Mar 01 2010

03/01/10
 
Old 10-21-2010, 08:29 AM   #3
johnshen64
LQ Newbie
 
Registered: Jun 2010
Posts: 29

Rep: Reputation: 5
just use the buildin read command to read in the string.

maybe you are talking about date format conversion. date -d '12/04/2010' should parse it correctly and you can format it to whatever other format you need by using a format string.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read the Daylight Saving Start date in C/C++? suryaemlinux Programming 13 01-28-2010 12:11 PM
Bash script to read file and alter lines depending on create date ChristianHein Linux - General 13 08-04-2007 05:39 AM
Cannot read package date from support.... gMp Linux - Software 1 09-18-2005 01:17 PM
Is it possible to read BIOS date? neo_in_matrix Programming 4 02-27-2005 06:38 PM
php read file creation, modified date problem antony_csf Programming 3 08-18-2004 06:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration