linuxÃüÁîѧϰ±Ê¼Ç£¨7£©£ºmvÃüÁî
mvÃüÁîÊÇmoveµÄËõд£¬¿ÉÒÔÓÃÀ´Òƶ¯Îļþ»òÕß½«Îļþ¸ÄÃû£¨move (rename) files£©£¬ÊÇLinuxϵͳϳ£ÓõÄÃüÁ¾³£ÓÃÀ´±¸·ÝÎļþ»òÕßĿ¼¡£
1£®ÃüÁî¸ñʽ£º
mv [Ñ¡Ïî] Ô´Îļþ»òĿ¼ Ä¿±êÎļþ»òĿ¼
2£®ÃüÁÄÜ£º
ÊÓmvÃüÁîÖеڶþ¸ö²ÎÊýÀàÐ͵IJ»Í¬£¨ÊÇÄ¿±êÎļþ»¹ÊÇÄ¿±êĿ¼£©£¬mvÃüÁÎļþÖØÃüÃû»ò½«ÆäÒÆÖÁÒ»¸öеÄĿ¼ÖС£µ±µÚ¶þ¸ö²ÎÊýÀàÐÍÊÇÎļþʱ£¬mvÃüÁîÍê³ÉÎļþÖØÃüÃû£¬´Ëʱ£¬Ô´ÎļþÖ»ÄÜÓÐÒ»¸ö£¨Ò²¿ÉÒÔÊÇԴĿ¼Ãû£©£¬Ëü½«Ëù¸øµÄÔ´Îļþ»òĿ¼ÖØÃüÃûΪ¸ø¶¨µÄÄ¿±êÎļþÃû¡£µ±µÚ¶þ¸ö²ÎÊýÊÇÒÑ´æÔÚµÄĿ¼Ãû³Æʱ£¬Ô´Îļþ»òĿ¼²ÎÊý¿ÉÒÔÓжà¸ö£¬mvÃüÁ¸÷²ÎÊýÖ¸¶¨µÄÔ´Îļþ¾ùÒÆÖÁÄ¿±êĿ¼ÖС£ÔÚ¿çÎļþϵͳÒƶ¯Îļþʱ£¬mvÏÈ¿½±´£¬ÔÙ½«ÔÓÐÎļþɾ³ý£¬¶øÁ´ÖÁ¸ÃÎļþµÄÁ´½ÓÒ²½«¶ªÊ§¡£
3£®ÃüÁî²ÎÊý£º
-b £ºÈôÐ踲¸ÇÎļþ£¬Ôò¸²¸ÇÇ°ÏÈÐб¸·Ý¡£
-f £ºforce Ç¿ÖƵÄÒâ˼£¬Èç¹ûÄ¿±êÎļþÒѾ´æÔÚ£¬²»»áѯÎʶøÖ±½Ó¸²¸Ç£»
-i £ºÈôÄ¿±êÎļþ (destination) ÒѾ´æÔÚʱ£¬¾Í»áѯÎÊÊÇ·ñ¸²¸Ç£¡
-u £ºÈôÄ¿±êÎļþÒѾ´æÔÚ£¬ÇÒ source ±È½ÏУ¬²Å»á¸üÐÂ(update)
-t £º --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY£¬¼´Ö¸¶¨mvµÄÄ¿±êĿ¼£¬¸ÃÑ¡ÏîÊÊÓÃÓÚÒƶ¯¶à¸öÔ´Îļþµ½Ò»¸öĿ¼µÄÇé¿ö£¬´ËʱĿ±êĿ¼ÔÚÇ°£¬Ô´ÎļþÔÚºó¡£
4£®ÃüÁîʵÀý£º
ʵÀýÒ»£ºÎļþ¸ÄÃû
ÃüÁmv test.log test1.txt
Êä³ö£º
[root@localhost test]# ll ×Ü¼Æ 20 drwxr-xr-x 6 root root 4096 10-27 01:58 scf drwxrwxrwx 2 root root 4096 10-25 17:46 test3 drwxr-xr-x 2 root root 4096 10-25 17:56 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 -rw-r--r-- 1 root root 16 10-28 06:04 test.log [root@localhost test]# mv test.log test1.txt [root@localhost test]# ll ×Ü¼Æ 20 drwxr-xr-x 6 root root 4096 10-27 01:58 scf -rw-r--r-- 1 root root 16 10-28 06:04 test1.txt drwxrwxrwx 2 root root 4096 10-25 17:46 test3 drwxr-xr-x 2 root root 4096 10-25 17:56 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 test5
˵Ã÷£º½«Îļþtest.logÖØÃüÃûΪtest1.txt
ʵÀý¶þ£ºÒƶ¯Îļþ
ÃüÁmv test1.txt test3
Êä³ö£º
[root@localhost test]# ll ×Ü¼Æ 20 drwxr-xr-x 6 root root 4096 10-27 01:58 scf -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxrwxrwx 2 root root 4096 10-25 17:46 test3 drwxr-xr-x 2 root root 4096 10-25 17:56 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 [root@localhost test]# mv test1.txt test3 [root@localhost test]# ll ×Ü¼Æ 16 drwxr-xr-x 6 root root 4096 10-27 01:58 scf drwxrwxrwx 2 root root 4096 10-28 06:09 test3 drwxr-xr-x 2 root root 4096 10-25 17:56 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 [root@localhost test]# cd test3 [root@localhost test3]# ll ×Ü¼Æ 4 -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt [root@localhost test3]#
˵Ã÷£º½«test1.txtÎļþÒƵ½Ä¿Â¼test3ÖÐ
ʵÀýÈý£º½«Îļþlog1.txt,log2.txt,log3.txtÒƶ¯µ½Ä¿Â¼test3ÖС£
ÃüÁ
mv log1.txt log2.txt log3.txt test3 mv -t /opt/soft/test/test4/ log1.txt log2.txt log3.txt
Êä³ö£º
[root@localhost test]# ll ×Ü¼Æ 28 -rw-r--r-- 1 root root 8 10-28 06:15 log1.txt -rw-r--r-- 1 root root 12 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt drwxrwxrwx 2 root root 4096 10-28 06:09 test3 [root@localhost test]# mv log1.txt log2.txt log3.txt test3 [root@localhost test]# ll ×Ü¼Æ 16 drwxrwxrwx 2 root root 4096 10-28 06:18 test3 [root@localhost test]# cd test3/ [root@localhost test3]# ll ×Ü¼Æ 16 -rw-r--r-- 1 root root 8 10-28 06:15 log1.txt -rw-r--r-- 1 root root 12 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt [root@localhost test3]# [root@localhost test3]# ll ×Ü¼Æ 20 -rw-r--r-- 1 root root 8 10-28 06:15 log1.txt -rw-r--r-- 1 root root 12 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt drwxr-xr-x 2 root root 4096 10-28 06:21 logs -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt [root@localhost test3]# mv -t /opt/soft/test/test4/ log1.txt log2.txt log3.txt [root@localhost test3]# cd .. [root@localhost test]# cd test4/ [root@localhost test4]# ll ×Ü¼Æ 12 -rw-r--r-- 1 root root 8 10-28 06:15 log1.txt -rw-r--r-- 1 root root 12 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt [root@localhost test4]#
˵Ã÷£ºmv log1.txt log2.txt log3.txt test3 ÃüÁlog1.txt £¬log2.txt£¬ log3.txt Èý¸öÎļþÒƵ½ test3Ŀ¼ÖÐÈ¥£¬mv -t /opt/soft/test/test4/ log1.txt log2.txt log3.txt ÃüÁîÓÖ½«Èý¸öÎļþÒƶ¯µ½test4Ŀ¼ÖÐÈ¥
ʵÀýËÄ£º½«Îļþfile1¸ÄÃûΪfile2£¬Èç¹ûfile2ÒѾ´æÔÚ£¬ÔòѯÎÊÊÇ·ñ¸²¸Ç
ÃüÁmv -i log1.txt log2.txt
Êä³ö£º
[root@localhost test4]# ll ×Ü¼Æ 12 -rw-r--r-- 1 root root 8 10-28 06:15 log1.txt -rw-r--r-- 1 root root 12 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt [root@localhost test4]# cat log1.txt odfdfs [root@localhost test4]# cat log2.txt ererwerwer [root@localhost test4]# mv -i log1.txt log2.txt mv£ºÊÇ·ñ¸²¸Ç¡°log2.txt¡±? y [root@localhost test4]# cat log2.txt odfdfs [root@localhost test4]#
ʵÀýÎ壺½«Îļþfile1¸ÄÃûΪfile2£¬¼´Ê¹file2´æÔÚ£¬Ò²ÊÇÖ±½Ó¸²¸Çµô¡£
ÃüÁmv -f log3.txt log2.txt
Êä³ö£º
[root@localhost test4]# ll ×Ü¼Æ 8 -rw-r--r-- 1 root root 8 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt [root@localhost test4]# cat log2.txt odfdfs [root@localhost test4]# cat log3 cat: log3: ûÓÐÄǸöÎļþ»òĿ¼ [root@localhost test4]# ll ×Ü¼Æ 8 -rw-r--r-- 1 root root 8 10-28 06:15 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log3.txt [root@localhost test4]# cat log2.txt odfdfs [root@localhost test4]# cat log3.txt dfosdfsdfdss [root@localhost test4]# mv -f log3.txt log2.txt [root@localhost test4]# cat log2.txt dfosdfsdfdss [root@localhost test4]# ll ×Ü¼Æ 4 -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt [root@localhost test4]#
˵Ã÷£ºlog3.txtµÄÄÚÈÝÖ±½Ó¸²¸ÇÁËlog2.txtÄÚÈÝ£¬-f ÕâÊǸöΣÏÕµÄÑ¡ÏʹÓõÄʱºòÒ»¶¨Òª±£³ÖÍ·ÄÔÇåÎú£¬Ò»°ãÇé¿öÏÂ×îºÃ²»ÓüÓÉÏËü¡£
ʵÀýÁù£ºÄ¿Â¼µÄÒƶ¯
ÃüÁmv dir1 dir2
Êä³ö£º
[root@localhost test4]# ll -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt [root@localhost test4]# ll -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt [root@localhost test4]# cd .. [root@localhost test]# ll drwxr-xr-x 6 root root 4096 10-27 01:58 scf drwxrwxrwx 3 root root 4096 10-28 06:24 test3 drwxr-xr-x 2 root root 4096 10-28 06:48 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 [root@localhost test]# cd test3 [root@localhost test3]# ll drwxr-xr-x 2 root root 4096 10-28 06:21 logs -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt [root@localhost test3]# cd .. [root@localhost test]# mv test4 test3 [root@localhost test]# ll drwxr-xr-x 6 root root 4096 10-27 01:58 scf drwxrwxrwx 4 root root 4096 10-28 06:54 test3 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 [root@localhost test]# cd test3/ [root@localhost test3]# ll drwxr-xr-x 2 root root 4096 10-28 06:21 logs -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxr-xr-x 2 root root 4096 10-28 06:48 test4 [root@localhost test3]#
˵Ã÷£ºÈç¹ûĿ¼dir2²»´æÔÚ£¬½«Ä¿Â¼dir1¸ÄÃûΪdir2£»·ñÔò£¬½«dir1Òƶ¯µ½dir2ÖС£
ʵÀý7£ºÒƶ¯µ±Ç°Îļþ¼ÐϵÄËùÓÐÎļþµ½ÉÏÒ»¼¶Ä¿Â¼
ÃüÁmv * ../
Êä³ö£º
[root@localhost test4]# ll -rw-r--r-- 1 root root 25 10-28 07:02 log1.txt -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt [root@localhost test4]# mv * ../ [root@localhost test4]# ll [root@localhost test4]# cd .. [root@localhost test3]# ll -rw-r--r-- 1 root root 25 10-28 07:02 log1.txt -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt drwxr-xr-x 2 root root 4096 10-28 06:21 logs -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxr-xr-x 2 root root 4096 10-28 07:02 test4
ʵÀý°Ë£º°Ñµ±Ç°Ä¿Â¼µÄÒ»¸ö×ÓĿ¼ÀïµÄÎļþÒƶ¯µ½ÁíÒ»¸ö×ÓĿ¼Àï
ÃüÁmv test3/*.txt test5
Êä³ö£º
[root@localhost test]# ll drwxr-xr-x 6 root root 4096 10-27 01:58 scf drwxrwxrwx 4 root root 4096 10-28 07:02 test3 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 [root@localhost test]# cd test3 [root@localhost test3]# ll -rw-r--r-- 1 root root 25 10-28 07:02 log1.txt -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt drwxr-xr-x 2 root root 4096 10-28 06:21 logs -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxr-xr-x 2 root root 4096 10-28 07:02 test4 [root@localhost test3]# cd .. [root@localhost test]# mv test3/*.txt test5 [root@localhost test]# cd test5 [root@localhost test5]# ll -rw-r--r-- 1 root root 25 10-28 07:02 log1.txt -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxr-xr-x 2 root root 4096 10-25 17:56 test5-1 [root@localhost test5]# cd .. [root@localhost test]# cd test3/ [root@localhost test3]# ll drwxr-xr-x 2 root root 4096 10-28 06:21 logs drwxr-xr-x 2 root root 4096 10-28 07:02 test4 [root@localhost test3]#
ʵÀý¾Å£ºÎļþ±»¸²¸ÇÇ°×ö¼òµ¥±¸·Ý£¬Ç°Ãæ¼Ó²ÎÊý-b
ÃüÁmv log1.txt -b log2.txt
Êä³ö£º
[root@localhost test5]# ll -rw-r--r-- 1 root root 25 10-28 07:02 log1.txt -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxr-xr-x 2 root root 4096 10-25 17:56 test5-1 [root@localhost test5]# mv log1.txt -b log2.txt mv£ºÊÇ·ñ¸²¸Ç¡°log2.txt¡±? y [root@localhost test5]# ll -rw-r--r-- 1 root root 25 10-28 07:02 log2.txt -rw-r--r-- 1 root root 13 10-28 06:16 log2.txt~ -rw-r--r-- 1 root root 29 10-28 06:05 test1.txt drwxr-xr-x 2 root root 4096 10-25 17:56 test5-1 [root@localhost test5]#
˵Ã÷£º
-b ²»½ÓÊܲÎÊý£¬mv»áÈ¥¶ÁÈ¡»·¾³±äÁ¿VERSION_CONTROLÀ´×÷Ϊ±¸·Ý²ßÂÔ¡£
--backup¸ÃÑ¡ÏîÖ¸¶¨Èç¹ûÄ¿±êÎļþ´æÔÚʱµÄ¶¯×÷£¬¹²ÓÐËÄÖÖ±¸·Ý²ßÂÔ£º
1.CONTROL=none»òoff : ²»±¸·Ý¡£
2.CONTROL=numbered»òt£ºÊý×Ö±àºÅµÄ±¸·Ý
3.CONTROL=existing»ònil£ºÈç¹û´æÔÚÒÔÊý×Ö±àºÅµÄ±¸·Ý£¬Ôò¼ÌÐø±àºÅ±¸·Ým+1...n£º
Ö´ÐÐmv²Ù×÷Ç°ÒÑ´æÔÚÒÔÊý×Ö±àºÅµÄÎļþlog2.txt.~1~£¬ÄÇôÔÙ´ÎÖ´Ðн«²úÉúlog2.txt~2~£¬ÒÔ´ÎÀàÍÆ¡£Èç¹û֮ǰûÓÐÒÔÊý×Ö±àºÅµÄÎļþ£¬ÔòʹÓÃÏÂÃæ½²µ½µÄ¼òµ¥±¸·Ý¡£
4.CONTROL=simple»ònever£ºÊ¹Óüòµ¥±¸·Ý£ºÔÚ±»¸²¸ÇÇ°½øÐÐÁ˼òµ¥±¸·Ý£¬¼òµ¥±¸·ÝÖ»ÄÜÓÐÒ»·Ý£¬Ôٴα»¸²¸Çʱ£¬¼òµ¥±¸·ÝÒ²»á±»¸²¸Ç¡£
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ