![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| changing the format of date in unix | trichyselva | UNIX for Dummies Questions & Answers | 5 | 03-20-2008 09:07 AM |
| convert mmddyy date format to ccyyddd format?? | Bhups | Shell Programming and Scripting | 2 | 09-27-2006 08:30 PM |
| changing the format of date | nasirgondal | Post Here to Contact Site Administrators and Moderators | 1 | 06-07-2006 10:37 PM |
| Changing the format of date | nhatch | UNIX for Dummies Questions & Answers | 4 | 04-11-2006 07:17 AM |
| Changing date format | Sabari Nath S | Shell Programming and Scripting | 5 | 12-06-2005 11:38 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Changing the date format
Hi,
I know there is a Q/A section and lots of posts regarding date command here. I am sorry to start a new thread. I am very new to shell scripting (actually i am working on my first program), so please forgive my ignorance. I could not find an answer to my problem else where so i posted it here. I appreciated if anyone would refer me to a source where i can get my answer or give me some suggestions on how to resolve the matter. This is what i need to do: I am trying to use a shell script in Linux to read the current time and change the format to M_D_YYYY. then the program needs to search the current directory for a file named "InfoM_D_YYY" (for example 'Info6_7_2005' ), read the file and write the data in separate variables. When i use the date command, the out put is formated as follows: Tue Jun 7 12:55:12 UTC 2005 I do nto know how i can change this format to M_D_YYYY and save in a variable which i can later ue to search for a file named InfoM_D_YYYY. Again, I am sorry if this question is repetitive. Thank you, Nina |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
It did not work though. I got the following error: date: illegal time format usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] DT=: Command not found. Nina |
|
|||
|
Hi,
when i use DT=`date +"%m_%d_%Y"` in a tcsh shell, i get the message that DT=06_08_2005: Command not found. Actually for any variable assignment (even the very basic ones like var=10 i get the error message that var=10: Command not found. But in kshell it works fine. But it has the format of say 06_07_2005. Do you know how i can get rid of the 0's in month and day and get something like 6_7_2005. One more question, i do not understand why the same command works in kshell but not tcsh. can anyone explain please. Thank you Nina |
|||
| Google The UNIX and Linux Forums |