3 ms·
I just don't use rm directly, unless it's something very trivial and non-recursive. Start with ls, write out your path, execute it and check the results. If it
by 5e92cb50239222b 2y ago
I just don't use rm directly, unless it's something very trivial and non-recursive. Start with ls, write out your path, execute it and check the results. If it looks fine, Ctrl+P → Ctrl+A → Alt+D → rm → Enter. Takes maybe two seconds more than just using rm, and definitely saved me more time over the years.
- jjnoakes 2y agoI have a similar habit. I usually do "echo rm ..." or "echo destructive command ..." first, check the output (so wildcards are expanded, etc), and if I'm happy I bring the command back in the history and edit out the echo.
- jmholla 2y agoIn bash, you can alternatively replace your shortcuts Ctrl+P → Ctrl+A → Alt+D with `!:1-$`, where 1 is the index of the first argument you want from your previous command. So: ls [files ...] rm !:1-$ I personally find it faster to use bash's history expansion. But, we're talking about subsecond differences here.
- c17r 2y agoYou can also do: $ ls [files ...] $ ^ls^rm