3 ms·
Yes that's right it's the previous command from history. That way you run ls and see if it's the expected output, then rm to delete.
by mprovost 5y ago
Yes that's right it's the previous command from history. That way you run ls and see if it's the expected output, then rm to delete.
- BossingAround 5y agoPoint being that "ls /path; rm $!" deletes something entirely different than "/path". What you want is "ls /path; rm $_". Even then, the above is fairly pointless. At the time you look at what you are deleting, it's gone.
- witrak 5y agoI think you misunderstood the previous comment. I think that firstly "ls /path" is entered and if the result is ok, then "; rm $_" is added to the copy of the command then executed.
- BossingAround 5y agoYes, at which point you simply do: 1. ls /path 2. rm <esc><.> (where "escape" "dot" brings up last argument) without the need to fiddle around with dollar signs underscores, exclamation marks, etc. to prevent further mistakes (e.g. "was it $! or !$ ?", shell expansion, etc)