troubleshooting Question

Converting .csh to .bash script that removes directory using find and rm

Avatar of volleyballjerry
volleyballjerryFlag for United States of America asked on
Linux* BashScripting Languages
5 Comments2 Solutions118 ViewsLast Modified:
I am converting a one-line script from csh to bash. The script simply removes a directory as specified by an argument on the command line.

find $1/testdir -exec rm -Rf {} +

works perfectly.

The following - cleanup.bash:

find $1/testdir -exec rm -Rf {} +

results in the following error

$ bash cleanup.bash directory1
find: paths must precede expression:
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Been racking my brains trying all sorts of things for a day now with suggestions from google. Please note - from the command line, this works perfectly. Just does not run inside bash script.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros