Solved

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

Posted on 2014-01-15
3
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unix scripting question 1 115
Unix Command -- Challenging  question 7 102
Linux "time" command output redirection 16 226
capture vmstat info and insert it into an oracle table 31 62
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.

730 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