I would like to search for all the nohup.out
in my mounted filesystems, and delete them.
There are some directories and files whose filenames contain space, so I think of
xargs -0
.To be safe, I would like to interactively delete them, i.e. be asked if I really want to delete them. So I think of
rm -i
andxargs -p
I also would like to delete each found file seperately, so I think of
xargs -n 1
.
But the following command doesn't work in the way I hope.
locate -i nohup.out | xargs -0 -n 1 -p rm -i
It doesn't prompt each file to be removed and ask for my permission.
I wonder why and what command works as I hope?
By the way my xargs version is xargs (GNU findutils) 4.4.2. Can it be the reason?
locate
is only as good as the db it looks up. If you haven't runupdatedb
in a while, locate will be near useless. You'll want to usefind
. Additionally, you don't specify what doesn't work the way you hope? – ffledgling Feb 28 '16 at 00:06locate
afterupdatedb
, because it is faster. My command doesn't prompt each file to be removed and ask for my permission – Tim Feb 28 '16 at 00:07-i
torm
and it works just fine. – ffledgling Feb 28 '16 at 00:12locate
doesn't produce null-separated output by default, so you're creating a newline-separated list whichxargs -0
will treat as a single argument, no? – steeldriver Feb 28 '16 at 00:23