Move command from another directory
I need to move a file from another directory.
Suppose you开发者_如何学编程 are in this directory: /home/CurDic1
And my file is located in this directory: /usr/CurDic2
I need to write someting like this (I just made it up):
/usr/CurDic2:>cd /home/CurDic1 | mv file1.txt /home/CurDic1/SubDic1
mv path_to_source_file path_to_destination_file
You can add a full path to your move command. In your particular case, it will be :
mv /usr/CurDic2/file1.txt .
It is important to know that .
is the current directory.
If you want to move to /home/CurDic1/SubDic1
, you can do :
mv /usr/CurDic2/file1.txt /home/CurDic1/SubDic1/
Concerning your made up example, |
is known as a "pipe" and it is used to redirect the output from the left command to the input of the right column. For example cat file.txt | less
while redirect the content of file.txt to the less command which is used to scroll in long textual datas.
However you can do
cd /home/CurDic1; mv file1.txt /home/CurDic1/SubDic1
the ;
is a command separator, it means that the first command will be executed and then the next one. You can chain many commands like this : cmd1; cmd2; cmd3; etc
精彩评论