Skip to content

Instantly share code, notes, and snippets.

@ronaldwolvers
Created September 4, 2024 10:00
Show Gist options
  • Select an option

  • Save ronaldwolvers/4e7a98a692a4717723ece7c5400a0e65 to your computer and use it in GitHub Desktop.

Select an option

Save ronaldwolvers/4e7a98a692a4717723ece7c5400a0e65 to your computer and use it in GitHub Desktop.
Remove build subdirectories in Bash/ZSH (POSIX compliant)
#!/bin/bash
# Delete all directories that are called 'build' in the directory from where this script
# is invoked.
echo -e "Removing all 'build' subdirectories..."
# According to https://github.com/koalaman/shellcheck/wiki/SC2038 whitespaces are interpreted
# by xargs in an unsafe way, therefore -print0 was added to `find` and -0 to `xargs`.
#find . -name "build" -type d | xargs -t -I {} rm -rf {}
find . -name "build" -type d -print0 | xargs -0 -t -I {} rm -rf {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment