Skip to content Skip सामग्री के लिए


The Linux 'date' command 'लिनक्स' तिथि आदेश

लिनक्स

A command line tool that I find use for very frequently on Linux is the “date” command. एक कमांड लाइन उपकरण है कि मैं लिनक्स पर बहुत बार उपयोग के लिए मिल "तारीख" कमांड है. It's a pretty simple command that returns you the date and time when you call it without any options. यह एक बहुत आसान आदेश है कि तुम वापस करने की तारीख और समय है जब आप इसे किसी भी विकल्प के बिना फोन है. But when you begin to use some of the options it provides you with this tool can make your life much easier and fun. लेकिन आप विकल्पों में से कुछ का उपयोग यह आप इस उपकरण के साथ प्रदान करता है अपनी बहुत आसान है और मज़ा ज़िंदगी बना सकते हैं जब शुरू करते हैं. Let's take a closer look at the command itself and some of its options and the cool tricks that we can make it do. चलो ही और इसके विकल्प के कुछ और शांत चाल आदेश है कि हम ऐसा कर सकते हैं पर एक करीब देखो.

The first thing to do is to get the current date and time: पहली बात करने के लिए आज की तारीख और समय मिल जाता है:

# date # तारीख
Sun Dec 14 11:33:55 IST 2008 सूर्य दिसम्बर 14 11:33:55 IST 2008

This is the simplest use of this command. यह इस कमान के सरल उपयोग है. Now suppose you wanted to just get the date and nothing more: अब लगता है तुम सिर्फ तारीख लेकर और कुछ नहीं करना चाहता था:

# date +”%d” # तारीख + "% d"
14 14

If you want the date, complete with date, month, and year: यदि आप तारीख चाहते हैं, तिथि, महीने के साथ पूर्ण है, और वर्ष:

# date +”%d%m%y” # तारीख + "% d% मी% Y"
141208 141208

To get the day of the week along with the rest of the date: करने की तारीख के आराम के साथ सप्ताह के दिन हो:

# date +”%a%d%m%y” # तारीख + "% एक% d% मी% Y"
Sun141208 Sun141208

These are a few of the many possibilities that the “date” command offers you. इन कई संभावनाएं है कि तारीख "कमांड" आप की पेशकश की कुछ कर रहे हैं. Check out “date –help for options”. बाहर "तारीख की जाँच करें विकल्प के लिए मदद. Some interesting ones are: कुछ रोचक वाले हैं:

%D   date (mm/dd/yy) % D तिथि (mm / dd YY)
%d   day of month (01..31) (% 01 .. 31 महीने के दिन घ)
%m   month (01..12) % मीटर महीने (01 .. 12)
%y   last two digits of year (00..99) % y पिछले (00 .. 99 साल के दो अंक)
%a   locale's abbreviated weekday name (Sun..Sat) % एक स्थान संक्षिप्त काम करने के दिन नाम Sun. (. शनि)
%A   locale's full weekday name, variable length (Sunday..Saturday) % एक स्थान पूरा काम करने के दिन नाम, चर लंबाई (Sunday. शनिवार.)
%b   locale's abbreviated month name (Jan..Dec) % ख है locale संक्षिप्त नाम महीने (जनवरी दिसम्बर)
%B   locale's full month name, variable length (January..December) % बी है locale पूर्ण महीने का नाम, चर लंबाई (January. दिसम्बर.)
%H   hour (00..23) % एच घंटे (00 .. 23)
%I   hour (01..12) % मैं घंटे (01 .. 12)
%Y   year (1970…) % Y (वर्ष 1970 ...)

You can also do some fancy formatting. तुम भी कुछ फैंसी स्वरूपण कर सकते हैं. If you want to add a hyphen or a back-slash in between the different parts of the date: यदि आप एक हैफ़ेन या वापस में स्लेश जोड़ना चाहते हैं तारीख के विभिन्न भागों के बीच:

# date +”%d-%m-%Y” # तारीख + "% d-% मीटर% Y"
14-12-2008 14-12-2008

# date +”%d/%m/%Y” # तारीख + "% d /% मी /% Y"
14/12/2008 14/12/2008

You can also use spaces and commas. तुम भी रिक्त स्थान और अल्पविराम का उपयोग कर सकते हैं. Here's a pretty fancy example: यहाँ एक सुंदर कल्पना उदाहरण है:

# date +”%A,%B %d %Y” # तारीख + "% ए, बी%% d% Y"
Sunday,December 14 2008 रविवार दिसम्बर 14, 2008

Say you're writing a shell script to back up the logs form you server. कहते हैं कि तुम एक खोल स्क्रिप्ट को लॉग वापस लिख रहे हैं आप सर्वर के रूप में. You want the backup script to get the logs for the day before and back them up. आप बैकअप स्क्रिप्ट चाहते हैं कि दिन के लिए लॉग से पहले और उन्हें वापस ऊपर. Here's how you can get the previous day's date: यहाँ है तुम पिछले दिन की तिथि कैसे प्राप्त कर सकते हैं:

# date –date=”yesterday” तारीख तारीख # = कल ""
Sat Dec 13 12:04:03 IST 2008 शनि दिसम्बर 13 12:04:03 IST 2008

Similarly, you can also get tomorrow's date: इसी तरह, तुम भी कल की तारीख प्राप्त कर सकते हैं:

# date –date=”tomorrow” तारीख तारीख # = "कल"
Mon Dec 15 12:04:39 IST 2008 सोम दिसम्बर 15 12:04:39 IST 2008

You can get last or next month's date: आप या अगले महीने की आखिरी तारीख प्राप्त कर सकते हैं:

# date –date=”last month” तारीख तारीख # = "पिछले महीने"
Fri Nov 14 12:06:23 IST 2008 शुक्रवार नवम्बर 14 12:06:23 IST 2008

# date –date=”next month” तारीख तारीख # = "अगले महीने"
Wed Jan 14 12:06:25 IST 2009 बुध जनवरी 14 12:06:25 IST 2009

Pretty cool stuff, eh! बहुत अच्छा सामान, हाँ! You're just getting started. तुम बस शुरू हो रही है. You can customize the date you want more precisely than by day and week, and get the date five days ago or seven days from now: तुम तारीख आपको अधिक दिन और सप्ताह तक ठीक से अनुकूलित चाहते हो सकते हैं, और तारीख मिल पांच दिन पहले या सात दिन अब से:

# date –date=”5 days ago” तारीख तारीख = "5 दिन पहले" #
Tue Dec  9 12:08:26 IST 2008 Tue दिसम्बर 9 12:08:26 IST 2008

# date –date=”7 days” तारीख तारीख = "7 दिनों" #
Fri Dec 21 12:09:23 IST 2008 शुक्र दिसम्बर 21 12:09:23 IST 2008

You can even ask it more difficult questions such as: तुम भी इसे और अधिक कठिन प्रश्न जैसे पूछ सकते हैं:

# date –date='next Saturday' तारीख #-तारीख = 'अगले' शनिवार
Sat Dec 20 00:00:00 IST 2008 शनि दिसम्बर 20 00:00:00 IST 2008

Or something totally in the future: या भविष्य में पूरी तरह से कुछ:

# date –date='2 years 3 months 4 day' तारीख तारीख # = '2 साल 3 महीने 4 'दिन
Fri Mar 18 12:12:16 IST 2011 शुक्र मार्च 18 12:12:16 IST 2011

It's almost as if “date” speaks English. यह लगभग रूप में यदि "तारीख" अंग्रेजी बोलती है. I keep discovering new tricks. मैं नई तरकीबें खोज रखें. So play around with it and let me know if you find some new cool possibilities that I might not have discovered yet. तो यह आसपास के साथ खेलते हैं और मुझे यदि आप कुछ नया शांत संभावनाएं है कि मैं अभी तक नहीं हो पाया मिल पता है.

Posted in पोस्ट में Guest Blogger अतिथि ब्लॉगर , , Linux लिनक्स . .

Related Posts: संबंधित पोस्ट:

How to set the date on your Linux machine कैसे आपके Linux मशीन पर स्थापित करने की तारीख
How to save the output of a Linux command to a file कैसे एक फ़ाइल में एक Linux कमान के उत्पादन को बचाने के लिए
How to post to Twitter from the Linux command line कैसे Linux कमांड लाइन से चहचहाना पोस्ट करने के लिए
How to see a detailed history of the commands run in Linux कैसे Linux में चलाने के आदेश की विस्तृत इतिहास को देखने के लिए
How to download files from the Linux command line Linux कमांड लाइन से डाउनलोड फ़ाइलों को कैसे

One Response एक उत्तर

Stay in touch with the conversation, subscribe to the बातचीत के साथ संपर्क में रहो, की सदस्यता लें RSS feed for comments on this post आरएसएस के इस पोस्ट पर टिप्पणियों के लिए फ़ीड . .

  1. Vivek says विवेक कहते हैं,

    Good explanation. अच्छा विवरण. The -date option is actually with double-hyphen -तारीख विकल्प वास्तव में साथ है डबल हैफ़ेन
    # date –date='next Saturday' तारीख #-तारीख = 'अगले' शनिवार
    should be जाना चाहिए
    # date –date='next Saturday' तारीख #-तारीख = 'अगले' शनिवार



Some HTML is OK कुछ HTML है ठीक है

or, reply to this post via या, इस पोस्ट के माध्यम से जवाब trackback Trackback . .