![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Selecting a line value | unibboy | Shell Programming and Scripting | 4 | 02-12-2008 01:41 PM |
| tar - Selecting target dir | GNMIKE | UNIX for Dummies Questions & Answers | 3 | 11-05-2005 02:52 AM |
| selecting each paragraph and put it into a file...help me | swamymns | Shell Programming and Scripting | 2 | 10-04-2005 08:46 AM |
| Selecting information from several web pages... | Vishnu | UNIX for Dummies Questions & Answers | 2 | 11-06-2002 01:04 PM |
| Selecting unknown string. | Cameron | UNIX for Dummies Questions & Answers | 2 | 12-18-2001 11:48 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi everyone
really need some help with this one. Ive to write a script where the middle date has to be checked and made sure that it is the current date. 281220032812200328122003 This is the format ive to check the date in the middle is the current date. Can anyone help me with this one - PLEASE. Thanks |
| Forum Sponsor | ||
|
|
|
|||
|
I am not clear with your question, I assume you are asking for today' s date 29122003 to be searched in a file, then the below will work
str=`date -u +%d%m%Y` grep $str filename if [ $? -ne 0 ] then echo "Date was not found" exit 1 fi Regards JK Last edited by jayakhanna; 12-29-2003 at 07:46 PM. |
|
|||
|
Apologise for being so vague
I'l try explain again - fully I have to write a script that checks a file example - file1 in this file there is a line which looks like 291220032912200329122003 from this i have to make the script check that the date in the middle is the current date. i.e 291220032812200329122003 this would not be current date therefore i have to raise an alert(which im fine with) to bring this to our attention. This is my first attempt at writing a script so any help is really appreciated Is this any clearer? Thanks Last edited by vcardo10; 12-29-2003 at 05:04 AM. |
|
||||
|
OK, from what you stated, the script should check a string of 3 dates, and make sure that the date in the middle is the current date ( i.e. equal to todays date).
Will the date format always be: ddmmyyyy ? When the day value or the month value is less than 10, will the format still be ddmmyyyy (i.e 01102003 - have a leading zero?) If so, then the code I posted should work. |
||||
| Google The UNIX and Linux Forums |