Reputation: 3171
I am trying to empty a directory using the rm
program. I capture a path into a variable and go to use this like so:
rm $export_folder_path
rm: “/Users/ricky/Documents/Folder”: No such file or directory
There certainly is such a directory at the path. When I try this manually, without a variable, it works as expected.
rm "/Users/ricky/Documents/Folder"
Upvotes: 1
Views: 400
Reputation: 42999
If you are sure about removing the directory along with its contents, I would advise this:
rm -rf -- "$export_folder_path"
The double quotes will take care of any spaces in the name of the directory.
Upvotes: 1
Reputation: 123470
You're using fancy quotes in your assignment of export_folder_path
. These slanted Unicode quotes are not recognized as quotes by bash, and are therefore treated as literals.
This is usually due to copypasting from blogs, or using an editor or OS not intended for programmers such as Word or macOS.
Replace them with regular ASCII double quotes in your script, and disable "smart quotes" in your editor or OS.
Upvotes: 3