This post has moved! Click here to view the new home of this post.
For a lot of you it may be pretty obvious but I want to share a quick trick I thought of just now. Often I find myself renaming a file in a sub-directory and find it a pain to type the whole path twice.
mv my/long/path/file.txt my/long/path/newname.txt
However you can use shell expansion to make this easier.
mv my/long/path/{file,newname}.txt
I never thought of it earlier because I think of expansions like when creating multiple arguments of they same type (soruce files, packages to install...), but since the order is predictable it works well for specifying the from
and to
arguments for the mv
and cp
commands.
No comments:
Post a Comment