Solved

Need code formatting in unix

Posted on 2006-07-14
2
296 Views
Last Modified: 2010-04-21

In my unix script I am trying to print the current date and time and in the log file in prints like          200607130821
our dba wants it put in more readable form, COULD YOU PROVIDE ME THE CODE

I WANT TO CAPTURE BOTH STARTDATE WITH TIME AND  END DATE WITH TIME in more readable format, need it ASAP

ATTACHING THE CODE BELOW
----------------------------------------------
CURR_DATE=$(date +%m%d%Y)                  ;export CURR_DATE
echo "Script started at = ${CURR_DATE}"   >> ${LOG_FILE}

did not add the end date in my script yet
---------------------------------------------------
echo "Script completed at = ${CURR_DATE}"   >> ${LOG_FILE}


log file it prints in this format
----------------------------------------------
Script started at = 200607130821
0
Comment
Question by:shihabf
2 Comments
 
LVL 6

Accepted Solution

by:
bira earned 500 total points
ID: 17109235
it seems that the format you need is

date +%Y%m%d%H%M
0
 
LVL 8

Expert Comment

by:koppcha
ID: 17109676
give just date it will be readable.
CURR_DATE=$(date)

It will  be print something like this
Fri Jul 14 11:21:44 CDT 2006
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question