Last active
December 20, 2015 04:39
-
-
Save raphaelchaib/6072977 to your computer and use it in GitHub Desktop.
Exclude files and directories via Linux's shell, except some of them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| find . ! -name one ! -name two -maxdepth 1 -type f -delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ! negates the next expresso | |
| -name specifies a filename | |
| -maxdepth 1 will make find process the specified directory only (find per default traverses directories) | |
| -type f will process only files (and not for example directories) | |
| -delete will delete the files | |
| You can then tune the conditions looking at the man page of find | |
| keep in mind that the order of the elements of the expressions is significant (see the documentation) | |
| test your command first by using -print instead of -delete | |
| > find . ! -name u ! -name p -maxdepth 1 -type f -print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment