Two scenarios for moving a directory under the Linux MV command

Source: Internet
Author: User

The MV Mobile directory is divided into 2 scenarios:


The first type: The target directory is empty, the MV command can be used to move directly, use absolute path to execute or add parameter-F does not prompt whether to move.

[[email protected] ~]# mkdir 1[[email protected] ~]# mkdir/tmp/1[[email protected] ~]# MV 1//tmp/mv:overwrite '/TMP/1 '? N[[email protected]#/BIN/MV 1//tmp/


The second type: The target directory is non-empty, using absolute path execution will also prompt the directory non-empty can not move, need to add a parameter - b plus parameters can be moved, but also back up the target directory one copy. Back up Directory ~Express;

[[email protected] ~]# mkdir 2[[email protected ] ~]# mkdir /tmp/2[[email protected] ~]# touch /tmp/2/2.txt[[email  protected] ~]# /bin/mv 2/ /tmp//bin/mv: cannot move  ' 2/'  to  '/tmp /2 ': directory not empty[[email protected] ~]# ls /tmp/1  2   yum.log[[email protected]# /bin/mv -b 2/ /tmp/[[email protected] ~]#  ls /tmp/1  2  2~  yum.log 

2~ This directory to move the previous/tmp/directory, after the move added ~ to indicate a backup.


This article is from the "Model Student's Learning blog" blog, please be sure to keep this source http://8802265.blog.51cto.com/8792265/1626422

Two scenarios for moving a directory under the Linux MV command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.