How can I delete all files and subdirectories from current directory including current directory?
How can I delete all files and subdirectories from current directory including current directory?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Under bash with GNU tools, I would do it like that (should be secure in most cases):
not under bash and without GNU tools, I would use:
why this more secure:
--in cases our directory starts with a dash (non-bash:./before the filename)pwd -Pnot justpwdin cases where we are not in a real directory but in a symlink pointing to it.'s around the argument in cases the directory contains spacessome random info (bash version):
cd ..at the end can be omitted, but you would be in a non-existant directory otherwise…EDIT: As kmkaplan noted, the
--thing is not necessary, aspwdreturns the complete path name which always starts with/on UNIX