Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Jul 2018 12:54:02 -0700
From:      Kurt Buff <kurt.buff@gmail.com>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Problem deleting files
Message-ID:  <CADy1Ce59zRgWBrQxvKKm%2B3heiwHuG8onMUnZSHVRUp4ZwPLzQA@mail.gmail.com>
In-Reply-To: <85B4CFC22AC0CA70B917D42D@Pauls-MacBook-Pro.local>
References:  <85B4CFC22AC0CA70B917D42D@Pauls-MacBook-Pro.local>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jul 1, 2018 at 12:13 PM, Paul Schmehl <paul.schmehl@gmail.com> wrote:
> I have a problem with a directory full of files that I can't seem to delete.
>
> rm * returns argument list too long. So does file *
>
> find . -type f -exec rm [] \; returns rm: []: No such file or directory over
> and over again.
>
> ls | wc -l shows there's files there.
> ls | wc -l
> 5023368
>
> And ls -l actually lists the files:
> -rw-------  1 root  wheel    134 Jun  7  2015
> sess_19n679i71prvju8nuqsvd727o4
>
> If I try to delete that specific filename, it seems to work. (Running rm
> twice returns no such file the second time.) Yet the file count remains the
> same.
>
> I also tried rm -fr | ls -l | awk '{print $9}', which returned a list of
> filenames but didn't delete any of them.
>
> Nothing I've tried to delete these files seems to work. What can I do to get
> rid of these files?
>
> Paul Schmehl
> Independent Researcher

That the file count remains the same even after deleting a file seems
a bit suspicious. I'm not sure what to make of that.

But, perhaps a piecemeal approach? Assuming the files all begin
"sess_", perhaps start with 'rm sess_0*', then 'rm sess_1*', etc.

Tedious to be sure, and you might have to combine that approach with
the 'find' incantation you've also tried, but seems worth a try.

Even more tedious, but also worth trying: 'ls /directory >
/root/out.txt' and then loop through that file with rm.


Kurt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADy1Ce59zRgWBrQxvKKm%2B3heiwHuG8onMUnZSHVRUp4ZwPLzQA>