xargs rm -rf
?
Linux Mint
Linux Mint is a free Linux-based operating system designed for use on desktop and laptop computers.
Want to see the latest news from the blog? Set the Firefox homepage to:
where is a current or past release. Here's an example using release 21.1 'Vera':
https://linuxmint.com/start/vera/
for f in *; do ls $f | tail -n 2 | xargs rm -rf; done
You mean like that? rm -rf followed by a question mark does not inspire confidence XD
this will break pretty badly if you have filenames with spaces or newlines in them. so to make this actually robust, you now get to learn about find -print0
, xargs -0
, and why you always, always need to add ""
around variables in bash.
yes. that's what I suggested.. the question mark was there to ask you if you tried that :-D I'm at work, pretty busy :-D I hope you read the rm
manual.
-r
means recursive
-f
means force, which will delete the files/directories without interaction