tail

फ़ाइल और डायरेक्टरी

इस्तेमाल

tail -f [file]

फ़ाइल का अंत छापता है और -f के साथ उसे देखता रहता है; log rotate होने के बाद पीछा जारी रखने के लिए -F चाहिए।

आम विकल्प

विकल्पअर्थ
-nPrint the last N lines
-n +NStart at line N instead of counting from the end
-fKeep printing as the file grows
-FFollow by name and reopen the file after log rotation
-cPrint the last N bytes
-rBSD: print the lines in reverse order (GNU uses tac)

उदाहरण

tail -f app.log

Watches a log live; Ctrl-C stops.

tail -n +2 data.csv

Skips the header line.

tail -F /var/log/nginx/access.log

Keeps following after the log is rotated.

हटाना, मिटाना और ढूँढना। कुछ कमांड दोबारा नहीं पूछते, इसीलिए -i लगाने की आदत हाथ बचाती है।

कैसे पढ़ें

  • बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
  • तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
  • विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।

आम सवाल

Q. tail क्या करता है?

फ़ाइल का अंत छापता है और -f के साथ उसे देखता रहता है; log rotate होने के बाद पीछा जारी रखने के लिए -F चाहिए।

Q. इसे कैसे लिखें?

tail -f [file] — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

Q. कितने विकल्प जानने लायक़ हैं?

यहाँ 6 दिए हैं; पूरी सूची man tail में है। यह कमांड फ़ाइल और डायरेक्टरी में आती है।

मिलती-जुलती कमांड

man पेज: man tail