Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
04-22-2012, 01:10 AM
|
#1
|
Member
Registered: Sep 2005
Posts: 225
Rep:
|
date command
$(date +%e-%B-%Y)
what does e , B , Y stands for in this command ?
I guess Y =year
what does e and B stands for ?
|
|
|
04-22-2012, 01:20 AM
|
#2
|
Member
Registered: Mar 2010
Posts: 458
Rep:
|
The best is to do it yourself on server.
Here is a clue for you.
user01@user01-VirtualBox:~$ date +%e-%B-%Y
22-April-2012
user01@user01-VirtualBox:~$
---------- Post added 04-22-12 at 04:21 PM ----------
or you can look at man page and play with formatting 
|
|
|
04-22-2012, 01:32 AM
|
#3
|
Member
Registered: Sep 2005
Posts: 225
Original Poster
Rep:
|
Quote:
Originally Posted by sysmicuser
The best is to do it yourself on server.
Here is a clue for you.
user01@user01-VirtualBox:~$ date +%e-%B-%Y
22-April-2012
user01@user01-VirtualBox:~$
---------- Post added 04-22-12 at 04:21 PM ----------
or you can look at man page and play with formatting 
|
No. you misunderstood my post. I dont want to know its output because I know it. I meant the flag expansion
Quote:
I guess Y =year
what does e and B stands for
|
Please revert back if you still dont get the point.
|
|
|
04-22-2012, 01:38 AM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
man date
/FORMAT
Cheers,
Tink
|
|
|
04-22-2012, 01:54 AM
|
#5
|
Member
Registered: Sep 2005
Posts: 225
Original Poster
Rep:
|
Quote:
Originally Posted by Tinkster
man date
/FORMAT
Cheers,
Tink
|
thanks I have found these ...
FORMAT controls the output.
%Y year
%e day of month, space padded; same as %_d
%B locale’s full month name (e.g., January)
but why a "+" there in date +%e-%B-%Y
+ is used for String concatenation. I dont see any logic why + is used with date
|
|
|
04-22-2012, 01:58 AM
|
#6
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
From the man page:
date [OPTION]... [+FORMAT]
It's just used to tell date that the characters that come after it are the format string.
|
|
|
04-22-2012, 02:06 AM
|
#7
|
Member
Registered: Sep 2005
Posts: 225
Original Poster
Rep:
|
Quote:
Originally Posted by Nylex
From the man page:
date [OPTION]... [+FORMAT]
It's just used to tell date that the characters that come after it are the format string.
|
aah ...[ +FORMAT] ....I see there is + before format.
Why Linux developers has kept OPTION and FORMAT both in the manual ? they could just put either. Don't understand why both. How are they different from functional point of view ?
Last edited by Volcano; 04-22-2012 at 02:07 AM.
|
|
|
04-22-2012, 02:09 AM
|
#8
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
FORMAT is for the format string, while OPTION is for options like --date, --reference, etc. Also, date isn't developed by "Linux developers", but by GNU people. Their software is available for other platforms as well.
|
|
|
04-22-2012, 02:14 AM
|
#9
|
Member
Registered: Sep 2005
Posts: 225
Original Poster
Rep:
|
Quote:
Originally Posted by Nylex
FORMAT is for the format string, while OPTION is for options like --date, --reference, etc.
|
Does that mean FORMAT may not be available for other commands ...because all commands may not print and hence no output format required.
But options seems all commands require .
|
|
|
04-22-2012, 02:20 AM
|
#10
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
Obviously the arguments you can pass to a given command are specific to that command.
|
|
|
04-22-2012, 02:36 AM
|
#11
|
Member
Registered: Sep 2005
Posts: 225
Original Poster
Rep:
|
Quote:
Originally Posted by Nylex
Obviously the arguments you can pass to a given command are specific to that command.
|
Excellent. I got you. You are very much helpful. Thanks.
Can you please tell how do I print a date
(a) 7 days prior to the current date
(b) last date of the previous month
I'm trying to do this basically...
$ date -7 +%e-%B-%Y // this is not correct syntax I know
Whats the correct syntax here ?
and
$ last_date_of_previous_month+%e-%B-%Y // this is not correct syntax I know
Whats the correct syntax here ?
Last edited by Volcano; 04-22-2012 at 02:43 AM.
|
|
|
04-22-2012, 02:45 AM
|
#12
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
Did you look at the documentation for date? This is covered there. From the bottom of the man page:
A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. ... The date string format is more complex than is easily documented here but is fully described in the info documentation.
The "SEE ALSO" section tells you how to get to the info page. Once there, you want to look at the section "Date input formats".
|
|
|
04-22-2012, 02:47 AM
|
#13
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
I don't understand what you mean by two, but ...
Code:
date "+%e-%B-%Y" --date "today - 7 days"
15-April-2012
|
|
|
04-22-2012, 03:02 AM
|
#14
|
Member
Registered: Sep 2005
Posts: 225
Original Poster
Rep:
|
Quote:
Originally Posted by Tinkster
I don't understand what you mean by two, but ...
Code:
date "+%e-%B-%Y" --date "today - 7 days"
15-April-2012
|
This is OK.
How do I get the last date of the previous month in the same format ?
|
|
|
04-23-2012, 01:57 AM
|
#15
|
Senior Member
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420
|
Quote:
How do I get the last date of the previous month in the same format ?
|
Did you try looking through the man page of date?
|
|
|
All times are GMT -5. The time now is 02:08 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|