Ravindra Bagale · AWSसर्व coursesया course चे lessonsशोधाEnglish

AWS · मराठी आवृत्ती

4.2 find ने files शोधूया

रवींद्र बागले यांच्या course वर आधारित · सहज मराठीत explanation

grep file च्या आत शोधतो; find files स्वतः नाव, आकार, वेळ किंवा प्रकारावरून शोधतो. Disk भरला तर मोठ्या files शोधायला उपयोगी.

find /var/www -name "*.html"                 # by name
find / -iname "nginx.conf" 2>/dev/null       # case-insensitive, hide permission errors
find /var/log -type f -size +100M            # files bigger than 100 MB
find /tmp -type f -mtime +7                  # modified more than 7 days ago
find /tmp -type f -mtime +7 -delete          # ...and delete them
find /var/www/html -type d -exec chmod 755 {} \;   # run a command on each result
find . -type f -name "*.log" | xargs ls -lh

-delete file प्रत्यक्ष काढतो. आधी तो option न वापरता results पाहा. 2>/dev/null permission errors लपवतो; diagnosis साठी त्या errors महत्त्वाच्या असतील तर लपवू नका. Filename मध्ये spaces असतील तर xargs चं साधं उदाहरण अडू शकतं; robust वापरासाठी find -print0 आणि xargs -0 वापरा.

Lab

sudo find /var/log -type f -size +1M ने मोठ्या logs शोधा. sudo find /etc -name "*.conf" -mtime -2 2>/dev/null ने मागच्या दोन दिवसांत बदललेल्या config files पाहा.