find <DIRECTORY_PATH> -name \*<PATTERN>\* | zip <ZIP_FILE_NAME>.zip -@
Showing posts with label find. Show all posts
Showing posts with label find. Show all posts
How to zip files with a pattern in name into a single zip file
To zip files with a certain pattern in their name in a directory, we can combine find and zip command like below :
How to find the 10 largest file or directories in Linux
This finds the largest 10 files :
find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
This finds the largest 10 directories:
find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
You can easily change -10 to -n where n is the number of files/directories you are trying to find.
Labels:
admin,
bash,
cut,
du,
Enterpise Linux,
find,
linux,
linux administraion,
script,
shell,
sort,
system admin,
tail,
unix,
xargs
How to combine find and zip to compress WebLogic ADR directories
Weblogic Server has an ADR folder containing a sub directory called incident. This directory holds one directory for each incident that happens during an application lifetime.
Each of these individual incident folder can be several Mega Bytes so i use the following to zip them up and delete them. I set it as a cron to run every 5 minutes.
find /MW_HOME/user_projects/domains/my_domain/servers/AdminServer/adr/diag/ofm/apps/myapp/incident -iname "incdir_*" -type d -exec sh -c 'zip -r {}.zip {}' \; -exec rm -rf {} \;
Each of these individual incident folder can be several Mega Bytes so i use the following to zip them up and delete them. I set it as a cron to run every 5 minutes.
find /MW_HOME/user_projects/domains/my_domain/servers/AdminServer/adr/diag/ofm/apps/myapp/incident -iname "incdir_*" -type d -exec sh -c 'zip -r {}.zip {}' \; -exec rm -rf {} \;
Subscribe to:
Posts (Atom)