2. To delete all files with the exception of filename1 and filename2:
$ rm -v !("filename1"|"filename2")
**********************************************************
*(pattern-list) – matches zero or more occurrences of the specified patterns
?(pattern-list) – matches zero or one occurrence of the specified patterns
+(pattern-list) – matches one or more occurrences of the specified patterns
@(pattern-list) – matches one of the specified patterns
!(pattern-list) – matches anything except one of the given patterns
*************************************************************
* – matches zero or more characters
? – matches any single character
[seq] – matches any character in seq
[!seq] – matches any character not in seq
****************************************************************
3. The example below shows how to remove all files other than all .zip files interactively:
$ rm -i !(*.zip)
=====================================================================
4. Next, you can delete all files in a directory apart from all .zip and .odt files as follows, while displaying what is being done:
$ rm -v !(*.zip|*.odt)
=========================================================================
. Using a pipeline and xargs, you can modify the case above as follows:
$ find . -type f -not -name '*gz' -print0 | xargs -0 -I {} rm -v {}
**********************************************************
diag_alert_500.log
you can do = rm diag_alert_*.log
********************************************************
--------------------------------------### Mostly successful command ###-------------------------------
find /path/to/folder -mtime +90 -exec rm {} +
find /path/to/folder -mtime +90 -delete
find /path/to/folder -mtime +90 -print
No comments:
Post a Comment