Tag Archives: find

Search for files with certain size and extension

I was looking for a large PDF file that was above 100 MB. The file was inside thousands of other files and folders, so I used this command to find it: find . -type f -size +100M | grep -i … Continue reading

Posted in Linux | Tagged , , , | Leave a comment

Best way to exclude a folder from your search using the “find” command

I found it to be the fastest and most effective way to use the find command and exclude specific folders. That is using the “prune” option: find /FOLDER_TO_SEARCH_INSIDE -path /FOLDER_TO_EXCLUDE -prune -o -name ‘NAME_OR_PATTERN_TO_SEARCH_FOR’ -print That’s it, Enjoy! Source: https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command

Posted in Linux | Tagged , , , | Leave a comment

Delete files older than X days

find /path/to/folder -mtime +14 -exec rm {} \; This finds all files within that folder that are older than 14 days, then executes rm on them

Posted in Uncategorized | Tagged , , , , | Leave a comment

Bash Script To Find and Delete All Files Except Some When the filesystem reaches a specific size

#!/bin/sh # This script checks if the /siebel filesystem reaches the warning limit of free space# And then delete the old logs except those of last 12 hours warninglimit=1572864    # This number is in KB, it’s equal to 1.5 GB,                        … Continue reading

Tagged , | Leave a comment

"Find All EXCEPT" using bash script

find . \( ! -name “hobba*” \) The above command invokes the “find” command asking it to search in the current directory (“.”) and return all files except those starting with the string “hobba”. Note: Take care of the spaces … Continue reading

Tagged , | Leave a comment