Skip to main content

Posts

Showing posts with the label UNIX

Common UNIX Find Commands

One of the most useful utilities in the UNIX systems resources directory is the find command. System administrators use this powerful utility frequently. Here are a few common tasks performed by the ubiquitous find command. I'll add more as time goes on. # cd /export/home/esofthub Find a file or directory # find . -name TEMP -print or # find . -name TEMP -exec echo {} \; Find core files in this directory tree and remove them # find . -name "core" -exec rm -f {} \; Find junk directories and remove their contents recursively # find . -name "junk" -exec rm -rf {} \; Find files not starting with "junk" OR not ending with "log" # find . ! \( -name "junk*" -o -name "*log" \) -print Find a pattern in a file using the recursive grep (ignore case) # find . -type f | xargs grep -i  MYPATTERN # find . -name '*.sh' -exec grep -i  MYPATTERN  {} \; Find files modified in the past 7 days # find . -mtime -7 -type f Find files owne...