General > General Technical Chat
Linux RM Command Help
Cerebus:
--- Quote from: PaulAm on December 23, 2021, 03:19:29 pm ---This is Unix, there's at least 20 different ways to achieve the identical result. It's not elegant unless the command looks like line noise :-DD
--- End quote ---
I know you're joking, but I'll still take strong objection to that. The original Unix design philosophy, and stated as such in the original papers on it, was that a command should do "one thing only, and do that one thing well". Then people ignored that and you got abominations like 'find' where there are options for everything under the sun, and it is far from the worst example there is. Commands like 'find' and 'rdist' are boobytrapped by the range of choices; if you're going to do something non-reversable with them you always need to run a non-destructive test case first to be sure that that you're going to get what you thought you were asking for. "rm -rf" is no less potentially destructive, but you at least get what you should have clearly known you were asking for.
SiliconWizard:
--- Quote from: PaulAm on December 23, 2021, 03:19:29 pm ---This is Unix, there's at least 20 different ways to achieve the identical result. It's not elegant unless the command looks like line noise :-DD
--- End quote ---
While many commands look a bit cryptic, they are powerful and avoid having to write your own tools most of the time. That's the key point. Take it or leave it. Yes, there is a learning curve.
--- Quote from: PaulAm on December 23, 2021, 03:19:29 pm ---There must be 50 different ways to delete your files ...
--- End quote ---
I don't see why this is a problem. Unless you were using a very crippled system, there will always be tons of different ways of solving a given problem.
PaulAm:
No time to write the lyrics, but if Paul Simon was a Unix nerd he might have penned a song with that name.
Find has been around since Version 5 days so it's part of Unix culture even it it doesn't quite fit the ideal design paradigm (it was written along with cpio). We could get into a black hole on how the current kernel and system development path diverges from the original goals, but that's too far off the topic.
The point of having "small tools that do one thing" is that multiple tools can be cobbled together to do a task, but different tools can be combined in different ways to achieve the same task. This is not a bad thing. Beats the heck out of point and click.
eti:
--- Quote from: Nominal Animal on December 23, 2021, 07:47:32 am ---
--- Quote from: eti on December 22, 2021, 08:01:41 pm ---
--- Code: ---for f in {0..9}; do rm *.old$f; done
--- End code ---
--- End quote ---
--- Quote from: eti on December 23, 2021, 07:15:26 am ---Keep it simple.
--- End quote ---
In Bash and POSIX shells,
rm *.old[0-9]
deletes exactly the same files. The only difference is that this does not complain if one of the files does not exist, while your loop does complain (assuming POSIX default or typical rm behaviour).
Why are you calling a shell loop "elegant", when a single command suffices? While telling others to Keep it simple?
>:D, of course.
--- End quote ---
Your method was unknown to me, but now I see it is more elegant, thanks.
cdev:
I alias rm to rm -i as a safety measure, usually. It can save your ass.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version