Changes

Jump to navigation Jump to search
1,121 bytes added ,  11:58, 25 October 2016
just catting around
sudo find /backups -mtime +30 -exec rm {} \;
</source>
 
== Reports with Find ==
Want to see all the <code>.htaccess</code> files in your webroot and see what they do? You can use <code>-exec bash -c</code> to perform multiple commands with one exec. (you can also use multiple -exec options in find). The example below echo's out the name of the found file; then cat's it with numbered lines. Note that the underscore is a throwaway value (could be any text, such as 'foobar') which consumes the first positional argument ($0) to <code>bash -c</code> making it "more readable" to reference our found filename as $1 (since $0 is commonly understood to refer to the script itself).
<source lang="bash">
# All give similar output
find _mw -name .htaccess -exec bash -c 'echo -e "\n$1\n"; cat -n "$1"' _ '{}' \;
find _mw -name .htaccess -exec bash -c 'echo -e "\n$0\n"; cat -n "$0"' '{}' \;
find _mw -name .htaccess -exec bash -c 'echo -e "\n$0$1\n"; cat -n "$1"' 'Reporting on ' '{}' \;
find _mw -name .htaccess -exec echo -e "\nReporting on " '{}' "\n" \; -exec cat -n '{}' \;
</source>
<ref>https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands</ref>
{{References}}
4,558

edits

Navigation menu