Is there a way to move a file from a directory to another and then cd into the latter in one command? Something like mv /a/file /another/dir && cd _ but without typing second time the directory path.
Tell me more
×
Unix & Linux Stack Exchange is a question and answer site for
users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
|
There are some functions for moving and copying files and following them to the destination directory originating from a thread on the Arch Linux boards:
You can then {move,copy} and follow a file by issuing:
|
|||||
|
|
in your
thats how i would do it then you would use
and it will copy blah to dir and if that was successful it will change directories to dir/ |
|||||||
|
|
You can do it forwards:
Or you can do it backwards:
Your call. |
||||
|
|
|
Test this option, try using verbose mv command to extract the directory and then go to the.
|
|||
readlinelibrary,Alt-.(assuming your terminal treats Alt as Meta) is a very handy interactive keyboard shortcut to know. It runs theyank-last-argreadline command, which pastes the last argument to the previous command. It even cycles when used repeatedly. – jw013 Oct 3 '12 at 19:32!$is the last arg of the last command ran. – h3rrmiller Oct 3 '12 at 19:34!$is indeed the last argument of the last command, but it is history expansion syntax, which is completely different from an environment variable. If you prefer,_IS a shell variable inbashthat corresponds to roughly the same thing. Note that history expansion is typically not enabled in non-interactive shells. – jw013 Oct 4 '12 at 14:55$_until just now. I guess I've been doing it the hard way until now. – h3rrmiller Oct 4 '12 at 17:42