Im using Amazon Linux, bash shell.  Im trying to write a statement that will delete all child directories named target within a specific master directory.  I would like to write things such that even if the directories dont exist, there is no error thrown.  I tried the below but Im getting an error[jboss@mydevbox ~]$ find ~/.jenkins/jobs/subco/workspace/myproject/ -name 'target' -print0 | xargs rm -rfxargs: Warning: a NUL character occurred in the input.  It cannot be passed through in the argument list.  Did you mean to use the --null option?What is a better way to write the above?
Having trouble deleting specific directories within a specific parent directory
bash;shell;find;rm
If you're using -print0 you should use the -0 flag to xargs so it will read the names correctly.find ~/.jenkins/jobs/subco/workspace/myproject/ -name 'target' -print0 | xargs -0 rm -rfalternately, if you have GNU find you could use the -delete flag, though it won't work if the directories are not empty find ~/.jenkins/jobs/subco/workspace/myproject/ -name 'target' -deleteOr, you could also use -exec with find likefind ~/.jenkins/jobs/subco/workspace/myproject/ -name 'target' -exec rm -rf {} +