Importanat UNIX commands


1. How do you delete 3 days old log files?

    Usage: find /location -name "*.log" -mtime +3 -exec rm -rf{} \;

    Example : find ./ -name "*.req" -mtime +4 -exec ls -ltr {} \;

2. Display latest 20 largest files/directories in current directory?

    Solution: du -ka sort -n tail -20

3. How do you display/remove Specifice Month files in Unix?

    Solution: rm `ls -l grep Jun awk '{print $9}'`

4. How do you find the files which contains a specific Word?
    
    Solution : find /home/joe \( -type f \) -exec grep -l test {} \;

No comments:

Post a Comment