How can I delete contents in a folder using a bash script?

~ is a shorthand to a current user home directory. So unless it's also your project directory you are doing something wrong. Other than that, clearing a directory would be

rm -rf ~/bin/*

And if you also want to clear the hidden files

rm -rf ~/bin/* ~/bin/.[a-zA-Z0-9]*

Make sure you are not doing

rm -rf ~/bin/.*

especially as root as it will try to clear out your entire system.

UPD

Why? Since wildcard (*) is interpreted by shell as zero or more characters of any kind the .* will also match . (current directory) and .. (parent directory), which will result in going all the way up and then down, trying to remove each file in your filesystem tree.


You should say "... my bin folder", not "my /bin folder". /bin is an absolute path, bin is a relative path.

rm -rf ~/bin removes $HOME/bin, so not what you want either.

Now, it depends on where you are: if you are in your project directory when you type the command, just type rm -rf bin.