For every file found, the `rm` command will be run, and ` \ Searching and Interacting with File Contents Using Grep and Sed Using `-exec` and `rm`, we can perform the equivalent of `-delete` from the example above. However, you will not always want to delete files once you’ve found them, so it is important to know how to execute an arbitrary command. Click here to try SmartFile for free, no credit card required. Need a good way to do this? Create a script and backup your files to SmartFile on a routine basis. Ask yourself what you’re trying to accomplish and always keep a backup of your files. Pro Tip: Don’t delete without fully considering the consequences. If the results look good, you can easily pass the `-delete` option to get rid of them: ~]$ find. We’ll specify the location to look (the current directory: “.”), that we’re only interested in files (type -f) and specify that the name of the file must end with “bu” (-name “*bu”). Let’s start with an example of using the `find` command to locate and remove some backup files that may be in the /etc directory. Keep reading to learn more about find, sed and grep! Find and Interact with Files This article will start with a relatively simple example and build towards a more advanced one.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |