-1

I would like to be able to do this

mv /long/path/to/file/old.txt /long/path/to/file/new.txt

without typing the directory twice. I imagine something like

rename /long/path/to/file/old.txt new.txt

Is this possible?

  • 1
    See recent (very similar) question [Can you conveniently rename a file without changing directory?](https://unix.stackexchange.com/questions/553136/can-you-conveniently-rename-a-file-without-changing-directory) – steeldriver Nov 21 '19 at 18:58

1 Answers1

2

You can do it with brace expansion:

mv /long/path/to/file/{old,new}.txt
bxm
  • 4,561
  • 1
  • 20
  • 21
  • 1
    The fun thing about brace expansion is that it's generative, rather than matching, so you can generate paths that don't exist yet. – stolenmoment Nov 24 '19 at 15:18