Solved

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

Posted on 2014-01-15
3
361 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 500 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 84

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.

803 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