3 ms·
I always like to do 'ls <pattern>' to see what I'm blowing away, then CTRL-a CTRL-D x2 rm Usually I know that I'm doing. Also like 'rm -fv' because feedback i
by smitty1e 3y ago
I always like to do 'ls <pattern>' to see what I'm blowing away, then CTRL-a CTRL-D x2 rm
Usually I know that I'm doing.
Also like 'rm -fv' because feedback is good.
- Galanwe 3y agoI have the same habit. I also use a somewhat similar "dry run" trick in `find` calls, such as: $ find foo/ -type f -name 'bar*' -exec echo rm {} \;
- smitty1e 3y agoYes, but I usually need to look up the -exec clause, because `{} \;` just feels hinky.
- upon_drumhead 3y agoModern versions has -delete as an option.
- JNRowe 3y agoThat is a GNU findutils extension, and modern means 2004 in this instance¹ ;) I spelunked because I thought "that always worked, didn't it?" ¹ https://git.savannah.gnu.org/cgit/findutils.git/tree/NEWS#n2153 https://git.savannah.gnu.org/cgit/findutils.git/tree/NEWS#n2...
- JNRowe 3y agoThere are few more general solutions to this interaction pattern(that also don't involve redundant history entries if you're OCD). * bash has a glob-expand-word function which will perform inplace expansion of patterns, it is bound to C-x* out of the box. Using it will expand the pattern before point. Depending on the keymap you're using it is available via the same binding or the expand-word function in zsh too. * C-xg (the glob-list-expansions function) will simply dump the expansion but retain the pattern in the command, if you'd prefer it didn't get added to history fully expanded for example. Again depending on keymap in zsh it is bound to the same key and calls the list-expand function. * You can recall combinations of arguments from any line in history, so in your example 'rm !*' would recall all the args to previous command. The main reason this is useful is that you can also apply substitutions to fix incorrect results, and also because you can target other lines not just the previous one. You can even tack a modifier on to print the result without executing to double-double-check things, should you be feeling super careful(rm !*:p). zsh supports the same syntax, but has advanced more advanced modification options.