Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

solars 10 bash : want to get date like 1/15/14 , i.e. m/dd/yy

Posted on 2014-01-15
3
Medium Priority
?
368 Views
Last Modified: 2014-01-15
hi

I am working on solars 10, and having query on simple bash command,
would like to get date like 1/15/14 , i.e. m/dd/yy , instead of mm/dd/yy

I can simply do like below, but I would like to remove 0 (zero) from month...

bash-3.2$ date "+%m/%d/%y"
01/15/14
bash-3.2$ date "+%D"
01/15/14

can somebody help me on simple scripting or command?
0
Comment
Question by:sleepingluke
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 39781986
bash-3.2$ date "+%m/%d/%y" | sed 's/^0//'
bash-3.2$ 1/15/14

bash-3.2$ MDY=$(date "+%m/%d/%y" | sed 's/^0//')
bash-3.2$ echo $MDY
bash-3.2$ 1/15/14

bash-3.2$ MDY=$(date "+%m/%d/%y")
bash-3.2$ echo ${MDY#0}
bash-3.2$ 1/15/14
0
 
LVL 85

Expert Comment

by:ozo
ID: 39782029
If you support GNU libc extension
date "+%-m/%d/%y"
0
 

Author Closing Comment

by:sleepingluke
ID: 39782071
thanks a lot both for support and though let me take this solution this time!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses

963 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