I have more than 1 million files (No directories). rm -rf * did not work.
How do i delete all these files at a stretch in a single command?
I have more than 1 million files (No directories). rm -rf * did not work.
How do i delete all these files at a stretch in a single command?
did you tried combining "ls" command with "rm"
offcourse you should have permissions.. is there any error message displayed..
find . -type f -exec rm {} \;
NOTE: it will delete all the files including the subdirectories.
rm -f should be fine.. no need of "r" option.. as this is for directory
I have logged in as root & have necessary permission (755), rm -f & "ls" command with "rm"
did not work as well.
Checking this .. find . -type f -exec rm {} \;
Why don't you try:
rm /directory/*
also you can add --force option and do check for the sticky bit also..
rm will fail with an error message of "Argument list too long" if there are too many files, try it with xargs:
find . -type f | xargs rm -f {} \;
Regards
the problem is the amount of files.
wehn you use the * in a shell, the sheel will REPLAE the * with the list of files, separated by spaces.
the problem ocurs because the arrar that is suposed to hold all the parameters (here, one param is one file) is not big enough to hold all the paramters.
this is simple avoided after you know the problem.
for example
ls | while read line
do
echo "this is one line: $line"
done
i suggest you make a text file with the dir listing, and analize what you want to delete.
after that, use the ls to wile bash script to delete what you want