I want to move a file from a directory different from the current directory. This is the solution I thought of:
mv (cd ~/Downloads; ls -t | head -1 | xargs -I {} readlink -f {}) ./
There is probably a better way, but along the way I found that my expectation of the change of directory staying inside the subcommand was wrong: Running cd changes the directory where mv
is being executed.
So, is there a way to change directories only for the current subcommand, without affecting the top command?