I accidentally copied the folders in my Music
directory to the parent michal
directory. I want to delete these directories in one fell swoop.
Is there any way to make the following work? Or is there a better alternative?
/home/michal/Music $ find . -type d -maxdepth 1 -exec rm -r ../{} \;
Evidently the {}
is not being substituted, because the above returns
rm: ../{}: No such file or directory
rm: ../{}: No such file or directory
rm: ../{}: No such file or directory
...
for f in *; if [ -d "$f" ] then rm -r ../"$f" ; fi; done
would something like that be acceptable? – Kalvin Lee Sep 27 '16 at 01:32for f in */; do rm -r ../"$f" ; done
– John1024 Sep 27 '16 at 01:34find -exec sh -c
safely? – G-Man Says 'Reinstate Monica' Sep 27 '16 at 05:07find
(link tobusybox
) is less robust than GNUfind
, and doesn’t accept all the commands that GNUfind
accepts. … (Cont’d) – G-Man Says 'Reinstate Monica' Sep 27 '16 at 06:30-exec cmd {} \;
works; it’s a question of whether-exec cmd ../{} \;
works. – G-Man Says 'Reinstate Monica' Sep 27 '16 at 06:30-exec rm -r ../{} \;
asbusybox find … -exec busybox rm -r ../{} \;
work. As long as there is a directory to erase. Not a problem of some busybox limitation IMO. – Oct 23 '16 at 19:24