Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /home/test
- /home/test/subdir1
- /home/test/subdir1/subdir2
- /home/test/subdir1/subdir2/subdir3
- /home/test/subdir1/subdir2/subdir4
- /home/test/subdir1/subdir2/subdir4/subdir5
- find . -type d -execdir pwd ;
- -exec command ;
- Execute command; true if 0 status is returned. All following
- arguments to find are taken to be arguments to the command until
- an argument consisting of ';' is encountered. The string '{}' is
- replaced by the current file name being processed everywhere it
- occurs in the arguments to the command, not just in arguments
- where it is alone, as in some versions of find. Both of these
- constructions might need to be escaped (with a ) or quoted to
- protect them from expansion by the shell. See the EXAMPLES sec‐
- tion for examples of the use of the -exec option. The specified
- command is run once for each matched file. The command is exe‐
- cuted in the starting directory. There are unavoidable security
- problems surrounding use of the -exec action; you should use the
- -execdir option instead.
- -execdir command ;
- -execdir command {} +
- Like -exec, but the specified command is run from the subdirec‐
- tory containing the matched file, which is not normally the
- directory in which you started find. This a much more secure
- method for invoking commands, as it avoids race conditions during
- resolution of the paths to the matched files. As with the -exec
- action, the '+' form of -execdir will build a command line to
- process more than one matched file, but any given invocation of
- command will only list files that exist in the same subdirectory.
- If you use this option, you must ensure that your $PATH environ‐
- ment variable does not reference '.'; otherwise, an attacker can
- run any commands they like by leaving an appropriately-named file
- in a directory in which you will run -execdir. The same applies
- to having entries in $PATH which are empty or which are not abso‐
- lute directory names.
- cd
- foo
- sh
- $OLDPWD
- $OLDPWD
- $OLDPWD
- find test/ -type d
- find /home/test/ -type d -exec bash -c '<Command to be executed>' ;
- find /home/test/ -type d -exec bash -c 'echo $0' ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement