0% found this document useful (0 votes)
8 views1 page

Advanced Shell Scripting Q&A Guide

Uploaded by

Deepak Sagar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Advanced Shell Scripting Q&A Guide

Uploaded by

Deepak Sagar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced-Level Shell Scripting Questions

Advanced-Level Shell Scripting Answers

1. Use grep with wc to count lines with the keyword: grep 'keyword' [Link] | wc -l.

2. Find and delete empty files: find . -type f -empty -delete.

3. Check symbolic links: if [ -L file ]; then echo "Symbolic link to $(readlink file)"; fi.

4. Merge CSVs: awk 'FNR==1 && NR!=1{next} 1' *.csv > [Link].

5. Recursive search: grep -r 'word' /path/to/directory.

6. Monitor disk usage: df -h | awk '$5+0 > 80 {print}' and send alerts.

7. Check and restart processes: ps aux | grep process_name || systemctl restart process.

8. Log uptime and load averages: uptime >> [Link].

9. Check CPU usage: ps -eo pid,%cpu,comm --sort=-%cpu | head -n 10.

10. Largest files: du -ah /path | sort -rh | head -n 5.

Page 1

You might also like