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

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

4.1 grep ने text शोधूया

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

Mauli Dairy च्या log मध्ये हजारो lines आहेत. Error असलेल्या lines शोधायला grep वापरतो; pattern जुळणाऱ्या lines तो print करतो.

Optionअर्थ
-iCase दुर्लक्षित
-r / -RFolders मध्ये recursive search
-nLine numbers
-vन जुळणाऱ्या lines
-cजुळणाऱ्या lines ची संख्या
-lफक्त file names
-wपूर्ण word
-EExtended regex: |, +, ? वगैरे
-A 3 / -B 3 / -C 3Match नंतर/आधी/दोन्हीकडे 3 lines
grep -i "error" /var/log/nginx/error.log
grep -rn "listen" /etc/nginx/
grep -v "^#" /etc/ssh/sshd_config | grep -v "^$"   # hide comments & blank lines
grep -c " 404 " /var/log/nginx/access.log          # how many 404s?
grep -E "Failed|Invalid" /var/log/auth.log         # Ubuntu SSH failures
sudo grep "Failed password" /var/log/secure         # AL2/CentOS (AL2023 uses journalctl)

Lab

sudo grep -v "^#" /etc/ssh/sshd_config | grep -v "^$" ने comments/blank lines वगळा आणि दिसणाऱ्या settings लिहा. पूर्ण effective SSH config मध्ये includes/defaults देखील असतात; ही फक्त file ची view आहे. Nginx असेल तर grep -c " 404 " /var/log/nginx/access.log करा; नसेल तर Chapter 6 नंतर करा.