Search code examples
linuxbashshellmvash

How to move file inside directory, using Linux (Bash)


I'm looking for a good shell one liner to move or rename a file inside a directory, where the target and destination parent directories are the same, and different than the current working directory. For example, the thing I don't want to write:

$ mv /usr/share/nginx/html/app.xml /usr/share/nginx/html/index.html

How can I do this same thing without typing '/usr/share/nginx/html/' twice or using multiple commands (to switch directory, pushd, etc)?


Solution

  • You can use braces expansion:

    $ mv /usr/share/nginx/html/{app.xml,index.html}