I need to clear and remove all files from a directory when using CentOS Linux. It worked:
cd dir1
rm *
But hidden files not cleared/deleted out. How do I do that?
I need to clear and remove all files from a directory when using CentOS Linux. It worked:
cd dir1
rm *
But hidden files not cleared/deleted out. How do I do that?
rm -r *
rm -rv {*,.*}
rm -rv /path/to/dir/{*,.*}
Another option set out dotglob option:
# set shell option
shopt -s dotglob
##################################################
# Remove all files including hidden . (dot) files
##################################################
rm -v /path/to/folder/*
rm -vrf ~/dir1/*
# unset
shopt -u dotglob
Where,
rm
means remove files-v
means verbose-f
means forceful removal of files-i
means get confirmation before removal of any filesSee our tutorial page for more information:
https://www.cyberciti.biz/faq/linux-delete-all-files-in-directory-using-command-line/