3 ms·
An alternative is: mv file.name !#:1.bak cp process.log !#:1.old !#:1 expands to the word with index 1.
by IngoBlechschmid 7y ago
An alternative is:
mv file.name !#:1.bak
cp process.log !#:1.old
!#:1 expands to the word with index 1.
- kesor 7y agoAnd it supports regex replace as well $ echo foobar !#:1:s/foo/bar echo foobar barbar foobar barbar
- garryq 7y agoslightly shorter !#$ and i always use ctrl-alt-e to expand and check even if i dont want to edit
- Anthony-G 7y agoI didn't know about the Ctrl-Alt-E so that's useful to know when using a new computer or a shared user account. I have `shopt -s histverify` set in my own bashrc. It's a useful sanity check when using history expansion. After typing the command, press Enter to see what it expands to, verify that it's what I intend and hit Enter a second time to confirm the comand.