News for hackers. Stuff that matters.
Re:Renaming files with mv without typing the name two times by IngoBlechschmid on Monday April 13, 2020 @08:12PM (#22861576)
An alternative is:

  mv file.name !#:1.bak
  cp process.log !#:1.old
!#:1 expands to the word with index 1.
Re:Renaming files with mv without typing the name two times by kesor on Monday April 13, 2020 @09:21PM (#22861908)
And it supports regex replace as well

    $ echo foobar !#:1:s/foo/bar
    echo foobar barbar
    foobar barbar
Re:Renaming files with mv without typing the name two times by garryq on Tuesday April 14, 2020 @04:31AM (#22863784)
slightly shorter !#$

and i always use ctrl-alt-e to expand and check even if i dont want to edit

Re:Renaming files with mv without typing the name two times by Anthony-G on Tuesday April 14, 2020 @07:42AM (#22864754)
I 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.