Tag Archives: find

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

Searching for a string inside multiple files and output the name of the files containing that string

find . -name “*” | grep -i ecomm | xargs ls -las | grep “Aug 27” | awk ‘{print $10}’ | xargs grep -i string_to_search_for | grep -i “\.log” | awk ‘{print $1}’ where: “ecomm” is part of the name … Continue reading

| Tagged , | Leave a comment

find files and copy them to a certain folder in bash (draft)

find . -name “*” | grep -i scomm | xargs ls -ltr | grep “Aug 13 10” | awk ‘{print $9}’ to use in the cp command (get the column number 9 which contains the file’s full path cp `find … Continue reading

| Tagged , , | Leave a comment

How to search for a string inside multiple text files

find starting_folder -name “*” | grep -i file_name | xargs grep -i search_string for example: “find . -name “*” | grep -i hobba | xargs grep -i tito” searches for the string “tito” inside all files whose name contains the … Continue reading

| Tagged , , | Leave a comment

How to search for a file using the "find" command in bash (not case sensitive)

find start_directory -name “*” | grep -i search_string e.g. “find . -name “*” | grep -i hobba” searches within the current directory and can return a file with name “aamr_HoBba.log” for example.

| Tagged , | Leave a comment