Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. /home/test
  2. /home/test/subdir1
  3. /home/test/subdir1/subdir2
  4. /home/test/subdir1/subdir2/subdir3
  5. /home/test/subdir1/subdir2/subdir4
  6. /home/test/subdir1/subdir2/subdir4/subdir5
  7.  
  8. find . -type d -execdir pwd ;
  9.  
  10. -exec command ;
  11. Execute command; true if 0 status is returned. All following
  12. arguments to find are taken to be arguments to the command until
  13. an argument consisting of ';' is encountered. The string '{}' is
  14. replaced by the current file name being processed everywhere it
  15. occurs in the arguments to the command, not just in arguments
  16. where it is alone, as in some versions of find. Both of these
  17. constructions might need to be escaped (with a ) or quoted to
  18. protect them from expansion by the shell. See the EXAMPLES sec‐
  19. tion for examples of the use of the -exec option. The specified
  20. command is run once for each matched file. The command is exe‐
  21. cuted in the starting directory. There are unavoidable security
  22. problems surrounding use of the -exec action; you should use the
  23. -execdir option instead.
  24.  
  25. -execdir command ;
  26. -execdir command {} +
  27. Like -exec, but the specified command is run from the subdirec‐
  28. tory containing the matched file, which is not normally the
  29. directory in which you started find. This a much more secure
  30. method for invoking commands, as it avoids race conditions during
  31. resolution of the paths to the matched files. As with the -exec
  32. action, the '+' form of -execdir will build a command line to
  33. process more than one matched file, but any given invocation of
  34. command will only list files that exist in the same subdirectory.
  35. If you use this option, you must ensure that your $PATH environ‐
  36. ment variable does not reference '.'; otherwise, an attacker can
  37. run any commands they like by leaving an appropriately-named file
  38. in a directory in which you will run -execdir. The same applies
  39. to having entries in $PATH which are empty or which are not abso‐
  40. lute directory names.
  41.  
  42. cd
  43.  
  44. foo
  45.  
  46. sh
  47.  
  48. $OLDPWD
  49.  
  50. $OLDPWD
  51.  
  52. $OLDPWD
  53.  
  54. find test/ -type d
  55.  
  56. find /home/test/ -type d -exec bash -c '<Command to be executed>' ;
  57.  
  58. find /home/test/ -type d -exec bash -c 'echo $0' ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement