Reputation
1,760
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
8 24
Newest
 Revival
Impact
~140k people reached

Mar
5
answered SSH X11 not working
Mar
1
revised How to keep Rsync from chown'ing transfered files?
added 120 characters in body
Feb
29
revised Change a non-striped LVM LV into a striped LV
added tag striping
Feb
29
suggested approved edit on Change a non-striped LVM LV into a striped LV
Feb
29
answered How to keep Rsync from chown'ing transfered files?
Feb
28
revised Resetting SP password using jumper P20 doesn't work on Sun Fire x4600 M2
added textual description for link
Feb
28
revised Sort a list of domain names (FQDNs) starting from tld and working left
added 381 characters in body
Feb
28
suggested approved edit on Resetting SP password using jumper P20 doesn't work on Sun Fire x4600 M2
Feb
28
revised Sort a list of domain names (FQDNs) starting from tld and working left
added 153 characters in body
Feb
28
awarded  Promoter
Feb
28
comment Sort a list of domain names (FQDNs) starting from tld and working left
Do you have timing information for this sort? I'm curious to see how this compares to @Mark-Henderson's PowerShell implementation, as well as my Python implementation. I used /usr/bin/time -v for the elapsed time and max memory stats.
Feb
28
comment Sort a list of domain names (FQDNs) starting from tld and working left
5 seconds seems like a long time for only 1,500 lines. My python implementation does 1,500 in a fraction of a second, and 150,000 in just over 3 seconds. What do you suppose makes it so slow in PowerShell?
Feb
28
revised Sort a list of domain names (FQDNs) starting from tld and working left
added 886 characters in body
Feb
28
answered Sort a list of domain names (FQDNs) starting from tld and working left
Feb
28
accepted Resetting SP password using jumper P20 doesn't work on Sun Fire x4600 M2
Feb
26
comment How do I prevent accidental rm -rf /*?
My intent is to provide a safe, general, effective, extensible answer to the original question: "How do I prevent accidental rm -rf /*?" Using find . -delete is safe(r) because it avoids this very common accidental mistake. It is also safer because makes it easy to preview the file list before deleting. It is a general method that works on any unix system and is not shell-dependent. It is effective because it accomplishes the same thing as rm -rf ./* but is more extensible, for example adding `-iname '*~' makes it easy to delete all *~ files in all subdirectories. How would rm do that?
Feb
26
comment How do I prevent accidental rm -rf /*?
Sure, so BSD find doesn't allow you to omit the directory, so you have find . -delete instead of find -delete. Also, the '*' glob may or may not expand dot files... it depends on a setting, which by default matches the behavior you describe, but if the system or someone has set shopt -s dotglob then it will expand dot files, too. If you are actually dealing with thousands of files you may also run up against the "Argument list too long" error, but that's another one you can avoid by using find.
Feb
26
comment How do I prevent accidental rm -rf /*?
It's clear you don't preview a list of files in your solution... that is exactly the point I'm making with find that you can do that easily simply by leaving off the -delete.
Feb
26
comment How do I prevent accidental rm -rf /*?
How is find -delete or find dir -delete a significant change in workflow? It accomplishes exactly the same thing as rm -rf ./* and 'rm -rf dir/*` without being prone to globbing errors or needing rubegoldberg-esque functions defined in .profile, plus if you want to preview the list of files before you delete them, just remove the -delete from the find command.
Feb
26
comment How do I prevent accidental rm -rf /*?
I understand what you are trying to do with set -f which is equivalently set -o noglob in Bash, but that still doesn't explain your statement that "The good thing about it is that it's only Bash". Instead you can eliminate the problem entirely and in a generic way for any shell by not using rm at all, but rather using the find command. Have you actually tried that suggestion to see how it compares with what you suggest here?