Quickest way to rename files, without retyping directory path
If your shell supported Brace Expansion (works with csh
, tcsh
, ksh
, zsh
, bash
, mksh
, lksh
, pdksh
, yash
with brace-expand enabled by calling yash --brace-expand
or set in interative shell with set -o brace-expand
, or fish
):
mv ~/folder/subfolder/file.{txt,sh}
You can also use rename
(part of the util-linux package).
rename .txt .sh ~/folder/subfolder/file.txt
See the rename man page for more details.
All the above are good. This would also work :
( cd ~/folder/subfolder && mv file.txt file.sh )