In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how Linux in the terminal according to your way to display the date and time, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Linux's date command provides a number of options for displaying dates and times, more than you might think. These are some useful options.
On Linux systems, the date command is very simple. You type date, and the date and time will be displayed in a useful way. It includes the day of the week, date, time and time zone:
$dateTue 26 Nov 2019 11:45:11 AM EST
As long as your system is configured correctly, you will see the date and current time as well as the time zone.
However, the command also provides a number of options to display date and time information in different ways. For example, if you want to display the date for sorting, you might need to use the following command:
$date "+% Y-%m-%d" 2019-11-26
In this case, the year, month, and day are arranged in that order. Notice that we use the capital letter Y to get a four-digit year. If we use lowercase y, we will only see a two-digit year (for example, 19). Don't let this make you mistakenly think that if% m gives you a numeric month,% M may give you the name of the month. No,% M will give you minutes. To get the month in the abbreviated name format, you use% b, and for fully spelled months, use% B.
$date "+% b% B" Nov November
Or, you may want to display the date in this common format:
$date "+% D" 11-26-19
If you need a four-digit year, you can do the following:
$date "+% x" 11Universe 26Universe 2019
Here is an example that might be useful. Suppose you need to create a daily report and include a date in the file name, you can use the following command to create the file (which may be used in the script):
$touch Report- `date "+% Y-%m-%d" `
When you list your reports, they will be listed in date order or reverse date order (if you add-r).
$ls-r Report*Report-2019-11-26Report-2019-11-25Report-2019-11-22Report-2019-11-21Report-2019-11-20
You can also add other details to the date string. There are a surprising number of options available. You can use date "+% Q" to show which quarter of the year you are in, or use a command similar to the following to display the date two months ago:
$date-- date= "2 months ago" Thu 26 Sep 2019 09:02:43 AM EDT
Do you want to know the date of next Thursday? You can use commands like date-date= "next thu", but understand that for Linux, next Thursday means the Thursday after today. If today is Wednesday, it will be tomorrow, not next Thursday. However, you can specify the Thursday of next week as the second command below.
$date-date= "next thu" Thu 28 Nov 2019 12:00:00 AM EST$ date-date= "next week thu" Thu 05 Dec 2019 12:00:00 AM EST
The man page of the date command lists all its options. The list is incredible, but you may find that some date / time display options are perfect for you. Here are some things you may find interesting.
World Standard time (UTC):
$date-uTue 26 Nov 2019 01:13:59 PM UTC
Number of seconds since January 1, 1970 (related to how dates are stored on Linux systems):
$date +% s1574774137
The following is a complete list of date command options. As I said, it is much more extensive than most of us think.
%% Show letter%
% a the abbreviated week name of the local locale (for example, day / Sun)
% A full week name of the local locale (for example, Sunday / Sunday)
% b abbreviated month name of the local locale (for example, one / Jan)
% B full month name of the local locale (for example, January / January)
C date and time of the local locale (e.g. Thursday, March 3, 2005, 23:05:25 / Thu Mar 3 23:05:25 2005)
% C Century; similar to% Y, but omitting the last two digits (for example, 20)
D days of the month (for example, 01)
D date; same as m/%d/%y
The day of% e month, fill in the prefix space; same as% _ d
% F full date; same as% Y-%m-%d
The last two digits of the year of% g ISO week number (see% G)
Year of% G ISO week number (see% V); usually used only with% V
H is the same as b
Hours of% H 24-hour system (00.23)
% I 12-hour hours (01.. 12)
% j days of the year (001. 366)
% k 24-hour hour, fill in the prefix space (0.23); same as% _ H
% l 12-hour hours, fill in the prefix space (1. 12); same as% _ I.
% m month (01.12)
% M minutes (00.59)
% n newline character
% N nanosecond (0000000.999999999)
% p string equivalent to AM or PM in the local locale; blank if unknown
% P is like% p, but in lowercase
% Q quarter (1.. 4)
% r 12-hour time for the local locale (for example, 11:11:04 / 11:11:04 PM)
Hours and minutes of% R 24-hour system; same as% Hpurs% M.
S seconds since 1970-01-01 00:00:00 UTC
% s seconds (00.60)
% t tab
T time; same as H:%M:%S
% u week (1. 7); 1 is Monday
The weekly number of% U year, with Sunday as the first day of the week, starting at 00. 53)
% V ISO Weekly account, with Monday as the first day of the week, starting at 01 (01.. 53)
% w week (0.6); 0 is Sunday
The weekly number of% W, Monday is the first day of the week, starting at 00 (00. 53)
% x date representation of the local locale (for example, 31 December 1999 / 12-31-99)
Time representation of% X local locale (for example, 23:13:48)
Last two digits of% y year (00.99)
% Y year
Numeric time zone in z + hhmm format (for example,-0400)
%: numeric time zone in z + hh:mm format (for example,-04:00)
%:: Z + hh:mm:ss format numeric time zone (for example,-04:00:00)
%:: Z numeric time zone,: indicates precision (for example,-04, + 05:30)
% Z letter time zone abbreviation (for example, EDT)
The above is all the contents of the article "how Linux displays the date and time in your way in the terminal". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.