Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find logfiles and move exclude one file name

Status
Not open for further replies.
Jun 21, 2006
6
US
Hi
I have an requirement to find all logfiles under a directory and move them to another partition. But I need to exclude all files begining with alert_.

I am using the following command to find and move all log files.

find $dirs -name "*.log" -o -name "*.trc" -o -name "*.trw" -o -name "core.*" -type f -size $limit -exec mv {} $2/ \;

could you please tell me how to apply the filter on it (Exclude files starting with name alert)

Regards
Upilli
 
find $dirs \( -name "*.log" -o -name "*.trc" -o -name "*.trw" -o -name "core.*" \) ! -name 'alert_*' -type f -size $limit -exec mv {} $2/ \;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Like this, I believe; not tested:

[tt]find $dirs \( -name "*.log" -a ! -name "alert_*" \) -o -name "*.trc" -o -name "*.trw" -o -name "core.*" -type f -size $limit -exec mv {} $2/ \;[/tt]

Try testing it by putting an echo before mv so that it does nothing but display the command.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top