stat कमांड
stat एक file पर library card के details पढ़ने जैसा है: यह कितनी बड़ी है, कौन इसे उपयोग कर सकता है और इसे last कब touch किया गया था। यह ls से मिलने वाले quick look से ज़्यादा दिखाता है।
In this page:
Syntax
stat file_name
stat
stat एक file के बारे में detailed metadata report करता है, size, permissions, और timestamps शामिल, ls -l से ज़्यादा comprehensively।
इसका exact output format Linux और macOS के बीच थोड़ा अलग है, लेकिन core information जो यह expose करता है वही है। यह अक्सर उन scripts में उपयोग होता है जिन्हें file size या modification time जैसी चीज़ें programmatically check करनी हों।
Note:
Linux पर
stat -c %s file उपयोग करें सिर्फ file size bytes में पाने के लिए, जो एक variable में capture करने के लिए suitable है।उदाहरण: stat
#!/bin/bash
echo "some sample content" > info.txt
stat info.txt
size=$(stat -c %s info.txt 2>/dev/null || stat -f %z info.txt)
echo "File size in bytes: $size"
Login to try C/C++/Java/PHP code in the editor
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- यह मानना कि
statके Linux और macOS पर same options हैं, क्योंकि format flags अलग हैं। - Spaces वाले file names के आस-पास quotes भूल जाना।
- Modification time (content बदला) को change time (metadata जैसे permissions बदले) के साथ confuse करना।
चैप्टर सारांश
-f,-d, और-eजैसे File tests जांचते हैं कि files और directories मौजूद हैं या नहीं और वे क्या हैं।- Reading, writing, appending, और line-by-line processing file contents handle करते हैं, और globbing file names match करता है।
find,cp,mv,rm, directory operations, permissions, औरstatfilesystem manage करते हैं।
🔒
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first: