11 Matching Annotations
  1. Last 7 days
  2. Apr 2020
    1. I had never considered it that in nearly a decade of using GNU find! Thank you for that! It will definitely change the way I think about -prune from now on.
    2. I think this structure is much easier and correlates to the right approach
    3. it isn't actually -prune itself that causes this, by the way. The issue is that the or operator "short-circuits", and or has lower precedence than and. The end result is that if a file called .snapshot is encountered it will match the first -name, -prune will then do nothing (but return true), and then the or returns true since its left-argument was true. The action (eg: -print) is part of its second argument, so it never has a chance to execute.
    4. If all you want to do is print the results you might be used to leaving out the -print action. You generally don't want to do that when using -prune.
    5. which means that it'll also print out the name of the directory you're pruning, which usually isn't what you want. Instead it's better to explicitly specify the -print action if that's what you want
    6. The thing I'd found confusing about -prune is that it's an action (like -print), not a test (like -name). It alters the "to-do" list, but always returns true.
    1. Did you expect the temp directory to get printed? In the last example, we saw the directories ./temp and ./C/temp got printed, but not now. This is the effect of the -print option. By default, the find command prints all the files matching the criteria. However, once the -print option is specified, it will print files only on explicit print instructions. In this find command, -print is associated in the other side of the OR condition, and hence nothing will get printed from the 1st part of the condition.
    2. 12. Same using the wholename option and prune to exclude directory: $ find . -wholename "./temp" -prune -o -perm 644 -print ./area.pm ./C/temp ./C/f2.c find has a switch with the name 'wholename'. Say, in your directory tree, there might be more than one temp directory. The earlier approaches will prune all the temp dierctories. In case, if the requirement is to prune a specific temp directory, then you can give the path of the directory itself. Note: The path specified in the wholename option should be relative to the search path specified, not the absolute path. 
  3. Dec 2019
    1. Using find and cpio is a more unix-y approach in that you let find do the file selection with all the power that it has, and let cpio do the archiving. It is worth learning this simple use of cpio, as you find it easy to solve problems you bang your ahead against when trying tar.
    2. find