mv Tips and Tricks

There are a couple tricks that can be used to make working with mv a little quicker and less painless. The first one is uses brace expansion to rename a file without having to type the full path twice[1]:

$ mv -v README.{md,org} ->

Globbing and brace expansion don't play together however, so if you want to move multiple files according to a pattern, you can use a simple for loop[2]:

$ touch {1,2,3,4,5}.txt
$ for file in *.txt; do
for> mv -v "$file" "${file%.txt}.md"
for> done
1.txt ->
2.txt ->
3.txt ->
4.txt ->
5.txt ->

There are other useful shortcuts for basic string manipulation in shell.

[2] StackExchange

View on Github