<em id="0a85b"><option id="0a85b"></option></em>

<abbr id="0a85b"></abbr>

      <nobr id="0a85b"></nobr>
        <tr id="0a85b"></tr>
        9久久伊人精品综合,亚洲一区精品视频在线,成 人免费va视频,国产一区二区三区黄网,99国产精品永久免费视频,亚洲毛片多多影院,精品久久久无码人妻中文字幕,无码国产欧美一区二区三区不卡
        學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > linux中的mv命令

        linux中的mv命令

        時(shí)間: 佳洲1085 分享

        linux中的mv命令

          Linux系統(tǒng)中的mv令是一個(gè)常用的基本命令,它的主要功能是對(duì)文件或目錄重命名,或者移除目錄。下面由學(xué)習(xí)啦小編為大家整理了linux中的mv命令的相關(guān)知識(shí),希望對(duì)大家有幫助!

          linux中的mv令詳解

          mv命令用來對(duì)文件或目錄重新命名,或者將文件從一個(gè)目錄移到另一個(gè)目錄中。

          注意事項(xiàng):mv與cp的結(jié)果不同,mv好像文件“搬家”,文件個(gè)數(shù)并未增加。而cp對(duì)文件進(jìn)行復(fù)制,文件個(gè)數(shù)增加了。

          (1)用法:

          用法: mv [選項(xiàng)]... [-T] 源文件 目標(biāo)文件

          或: mv [選項(xiàng)]... 源文件... 目錄

          或: mv [選項(xiàng)]... -t 目錄 源文件...

          (2)功能:

          將源文件重命名為目標(biāo)文件,或?qū)⒃次募苿?dòng)至指定目錄。

          (3)選項(xiàng)參數(shù):

          1) -b: 當(dāng)文件存在時(shí),覆蓋前,為其創(chuàng)建一個(gè)備份

          2) -f 若目標(biāo)文件或目錄與現(xiàn)有的文件或目錄重復(fù),則直接覆蓋現(xiàn)有的文件或目錄

          3) -i 交互式操作,覆蓋前先行詢問用戶,如果源文件與目標(biāo)文件或目標(biāo)目錄中的文件同名,則詢問用戶是否覆蓋目標(biāo)文件。這樣可以避免誤將文件覆蓋。

          4) -f -force 強(qiáng)制的意思,如果目標(biāo)文件已經(jīng)存在,不會(huì)詢問而直接覆蓋

          5) -u 若目標(biāo)文件已經(jīng)存在,且 source 比較新,才會(huì)更新(update)

          linux中的mv命令實(shí)例

          1)[sunjimeng@localhost Document]$ mv text1 mytext 由于此處源文件test1與目標(biāo)文件是在同一目錄下,可以看作僅僅是改了文件的名字

          [sunjimeng@localhost Document]$ ll //目錄下為空

          總用量 0

          [sunjimeng@localhost Document]$ cat >text1 <<EOF //新建文件文檔并從標(biāo)準(zhǔn)輸入中輸入數(shù)據(jù)到文件

          > I am MenAngel

          > PWD=$(pwd)

          > I am testing the order of mv!

          > EOF

          [sunjimeng@localhost Document]$ ll

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 text1

          [sunjimeng@localhost Document]$ mv text1 mytext //執(zhí)行mv命令

          [sunjimeng@localhost Document]$ cat mytext

          I am MenAngel

          PWD=/home/sunjimeng/Document

          I am testing the order of mv!

          [sunjimeng@localhost Document]$ ll //可見已經(jīng)改名

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext

          [sunjimeng@localhost Document]$

          2)[sunjimeng@localhost Document]$ mv mytext{,.txt} 與[sunjimeng@localhost Document]$ mv text text.txt 給文件名增加后綴

          [sunjimeng@localhost Document]$ mv mytext{,.txt} //增加后綴名的原始方法

          [sunjimeng@localhost Document]$ ll

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          [sunjimeng@localhost Document]$ touch text

          [sunjimeng@localhost Document]$ ll

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text

          [sunjimeng@localhost Document]$ mv text text.txt //利用mv的改名目錄增加后綴

          [sunjimeng@localhost Document]$ ll

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text.txt

          3)[root@localhost Documents]# mv ../Document/* . 將文件從源目錄移動(dòng)到目標(biāo)目錄,這里源目錄和目標(biāo)目錄可以任意指定。.代表當(dāng)前目錄

          [sunjimeng@localhost Document]$ ll //Document下游兩個(gè)文件

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text.txt

          [sunjimeng@localhost Document]$ cd ../Documents //進(jìn)入同級(jí)兄弟目錄Documents,發(fā)現(xiàn)其下為空

          [sunjimeng@localhost Documents]$ ll

          總用量 0

          [sunjimeng@localhost Documents]$ mv ../Document/* . //將Document下的所有文件(*),移動(dòng)到當(dāng)前目錄(.)。

          mv: 無法將"../Document/mytext.txt" 移動(dòng)至"./mytext.txt": 權(quán)限不夠 //Linux用組名和用戶名來管理文件,此時(shí)當(dāng)前用戶沒有權(quán)限移動(dòng)文件,必須改為root用戶

          mv: 無法將"../Document/text.txt" 移動(dòng)至"./text.txt": 權(quán)限不夠

          [sunjimeng@localhost Documents]$ su root

          密碼:

          ABRT 已檢測到 '1' 個(gè)問題。預(yù)了解詳細(xì)信息請(qǐng)執(zhí)行:abrt-cli list --since 1462423345

          [root@localhost Documents]# mv ../Document/* .

          [root@localhost Documents]# ll //移動(dòng)完成

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text.txt

          [root@localhost Documents]# ls -l ../Document //查看Document目錄已經(jīng)沒有任何東西

          總用量 0

          4)[root@localhost Documents]# mv -t ../Document ./* 功能同(3),但區(qū)別是源文件的路徑和目標(biāo)路徑的位置發(fā)生了變化

          [root@localhost Documents]# ll

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text.txt

          [root@localhost Documents]# mv -t ./* ../Document //-t參數(shù)的功能就是讓他們的位置發(fā)生變化,這里第一個(gè)參數(shù)是目標(biāo)路徑

          mv: 目標(biāo)"./mytext.txt" 不是目錄

          [root@localhost Documents]# mv -t ../Document ./* //位置調(diào)換一下就行了

          [root@localhost Documents]# ll

          總用量 0

          [root@localhost Documents]# ll

          總用量 0

          [root@localhost Documents]# ls -l ../Document

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text.txt

          5)[root@localhost Document]# mv mytext.txt mytext 如果第二個(gè)參數(shù)不是目錄名,才將源文件改名,否則,移動(dòng)源文件到該目錄下(與實(shí)例1作比較)

          [root@localhost Document]# mkdir mytext

          [root@localhost Document]# ll

          總用量 4

          drwxr-xr-x. 2 root root 6 5月 5 22:34 mytext

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text

          [root@localhost Document]# mv mytext.txt mytext //與實(shí)例一不同的是,這里mytext是個(gè)目錄

          [root@localhost Document]# ll

          總用量 0

          drwxr-xr-x. 2 root root 23 5月 5 22:35 mytext

          -rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 5 22:08 text

          [root@localhost Document]# ls -l mytext

          總用量 4

          -rw-rw-r--. 1 sunjimeng sunjimeng 73 5月 5 22:02 mytext.txt

          6)[root@localhost Document]# mv -b myword text 源文件和目標(biāo)文件都是存在的,因此會(huì)有覆蓋提醒,-b用于在覆蓋時(shí)備份文件

          [root@localhost Document]# cat >myword <<EOF

          > this is my word!

          > EOF

          [root@localhost Document]# cat >text <<EOF

          > this is my text!

          > EOF

          [root@localhost Document]# mv -b myword text //在一個(gè)文件即將覆蓋另一個(gè)文件時(shí),默認(rèn)是提醒的,所以加上-i參數(shù)和不加是一樣的

          mv:是否覆蓋"text"? y

          [root@localhost Document]# cat myword

          cat: myword: 沒有那個(gè)文件或目錄

          [root@localhost Document]# cat text

          this is my word!

          [root@localhost Document]# ll

          總用量 8

          drwxr-xr-x. 2 root root 23 5月 5 22:35 mytext //這里text里存的是前面myword的內(nèi)容,text的內(nèi)容備份到text~中,需要特殊軟件才能查看

          -rw-r--r--. 1 root root 17 5月 5 22:41 text

          -rw-rw-r--. 1 sunjimeng sunjimeng 17 5月 5 22:41 text~

          7) [root@localhost text]# mv * ../ 將當(dāng)前目錄下的所有內(nèi)容移動(dòng)到父級(jí)目錄(特殊情況)

          [root@localhost Document]# mkdir text

          [root@localhost Document]# touch ./text/{text1,text2,text3}

          [root@localhost Document]# cd text

          [root@localhost text]# mv * ../

          [root@localhost text]# cd ../

          [root@localhost Document]# ll

          總用量 0

          drwxr-xr-x. 2 root root 6 5月 5 22:57 text

          -rw-r--r--. 1 root root 0 5月 5 22:57 text1

          -rw-r--r--. 1 root root 0 5月 5 22:57 text2

          -rw-r--r--. 1 root root 0 5月 5 22:57 text3

          8)[root@localhost Document]# mv -f text2 text3 強(qiáng)制執(zhí)行操作,并不做任何提醒

          9)[root@localhost Document]# mv -i text2 text3 加不加-i在覆蓋時(shí)都會(huì)提醒

          [root@localhost Document]# ll

          總用量 0

          drwxr-xr-x. 2 root root 6 5月 5 23:05 text

          -rw-r--r--. 1 root root 0 5月 5 22:57 text2

          -rw-r--r--. 1 root root 0 5月 5 22:57 text3

          -rw-r--r--. 1 root root 0 5月 5 22:57 text4

          [root@localhost Document]# mv text2 text3

          mv:是否覆蓋"text3"? n

          [root@localhost Document]# mv -i text2 text3

          mv:是否覆蓋"text3"? n

          [root@localhost Document]# mv -f text2 text3

          [root@localhost Document]# ll

          總用量 0

          drwxr-xr-x. 2 root root 6 5月 5 23:05 text

          -rw-r--r--. 1 root root 0 5月 5 22:57 text3

          -rw-r--r--. 1 root root 0 5月 5 22:57 text4

          10)[root@localhost Document]# mv Dir text 將Dir目錄移動(dòng)到text目錄下(text存在時(shí)),如果不存在直接將Dir改名為text

          [root@localhost Document]# mkdir testDir

          [root@localhost Document]# ll //下面的操作先將文件text3和text4放到textDir目錄下

          總用量 0

          drwxr-xr-x. 2 root root 6 5月 5 23:09 testDir

          drwxr-xr-x. 2 root root 6 5月 5 23:05 text

          -rw-r--r--. 1 root root 0 5月 5 22:57 text3

          -rw-r--r--. 1 root root 0 5月 5 22:57 text4

          [root@localhost Document]# mv {text3,text4} ./testDir

          [root@localhost Document]# mv testDir Dir //由于Dir不存在,所以testDir改名為Dir

          [root@localhost Document]# mv Dir text //由于text是存在的,所以將Dir移到text目錄下

          [root@localhost Document]# ll

          總用量 0

          drwxr-xr-x. 3 root root 16 5月 5 23:10 text //下面驗(yàn)證了這一點(diǎn)

          [root@localhost Document]# cd text

          [root@localhost text]# ll

          總用量 0

          drwxr-xr-x. 2 root root 30 5月 5 23:09 Dir

          [root@localhost text]# cd Dir

          [root@localhost Dir]# ll

          總用量 0

          -rw-r--r--. 1 root root 0 5月 5 22:57 text3

          -rw-r--r--. 1 root root 0 5月 5 22:57 text4

          11)[root@localhost /]# mv --help

          [root@localhost /]# mv --help

          用法:mv [選項(xiàng)]... [-T] 源文件 目標(biāo)文件

          或:mv [選項(xiàng)]... 源文件... 目錄

          或:mv [選項(xiàng)]... -t 目錄 源文件...

          Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

          Mandatory arguments to long options are mandatory for short options too.

          --backup[=CONTROL] 為每個(gè)已存在的目標(biāo)文件創(chuàng)建備份

          -b 類似--backup 但不接受參數(shù)

          -f, --force 覆蓋前不詢問

          -i, --interactive 覆蓋前詢問

          -n, --no-clobber 不覆蓋已存在文件

          如果您指定了-i、-f、-n 中的多個(gè),僅最后一個(gè)生效。

          --strip-trailing-slashes 去掉每個(gè)源文件參數(shù)尾部的斜線

          -S, --suffix=SUFFIX 替換常用的備份文件后綴

          -t, --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY

          -T, --no-target-directory treat DEST as a normal file

          -u, --update move only when the SOURCE file is newer

          than the destination file or when the

          destination file is missing

          -v, --verbose explain what is being done

          -Z, --context set SELinux security context of destination

          file to default type

          --help 顯示此幫助信息并退出

          --version 顯示版本信息并退出

          The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.

          The version control method may be selected via the --backup option or through

          the VERSION_CONTROL environment variable. Here are the values:

          none, off 不進(jìn)行備份(即使使用了--backup 選項(xiàng))

          numbered, t 備份文件加上數(shù)字進(jìn)行排序

          existing, nil 若有數(shù)字的備份文件已經(jīng)存在則使用數(shù)字,否則使用普通方式備份

          simple, never 永遠(yuǎn)使用普通方式備份

          GNU coreutils online help: <http://www.gnu.org/software/coreutils/>

          請(qǐng)向<http://translationproject.org/team/zh_CN.html> 報(bào)告mv 的翻譯錯(cuò)誤

          要獲取完整文檔,請(qǐng)運(yùn)行:info coreutils 'mv invocation'

          12)[root@localhost /]# mv --version

          [root@localhost /]# mv --version

          mv (GNU coreutils) 8.22

          Copyright (C) 2013 Free Software Foundation, Inc.

          許可證:GPLv3+:GNU 通用公共許可證第3 版或更新版本<http://gnu.org/licenses/gpl.html>。

          本軟件是自由軟件:您可以自由修改和重新發(fā)布它。

          在法律范圍內(nèi)沒有其他保證。

          由Mike Parker、David MacKenzie 和Jim Meyering 編寫。

          補(bǔ)充:其他

          用-b做備份時(shí):

          -b 不接受參數(shù),mv會(huì)去讀取環(huán)境變量VERSION_CONTROL來作為備份策略。

          --backup該選項(xiàng)指定如果目標(biāo)文件存在時(shí)的動(dòng)作,共有四種備份策略:

          1.CONTROL=none或off : 不備份。

          2.CONTROL=numbered或t:數(shù)字編號(hào)的備份

          3.CONTROL=existing或nil:如果存在以數(shù)字編號(hào)的備份,則繼續(xù)編號(hào)備份m+1...n:

          執(zhí)行mv操作前已存在以數(shù)字編號(hào)的文件log2.txt.~1~,那么再次執(zhí)行將產(chǎn)生log2.txt~2~,以次類推。如果之前沒有以數(shù)字編號(hào)的文件,則使用下面講到的簡單備份。

          4.CONTROL=simple或never:使用簡單備份:在被覆蓋前進(jìn)行了簡單備份,簡單備份只能有一份,再次被覆蓋時(shí),簡單備份也會(huì)被覆蓋。

        3626106 主站蜘蛛池模板: 国产精品一线天粉嫩av| 伊人成人在线视频免费| 久久精品娱乐亚洲领先| 丰满少妇内射一区| 国产91精品一区二区蜜臀| 97色伦97色伦国产| 亚洲国产精品午夜福利| 亚洲欧美日韩尤物AⅤ一区| 久久精品无码一区二区国产区| 欧美福利电影A在线播放| 亚洲最大成人一区久久久| 精品精品国产国产自在线| 国产一区二区三区不卡视频| 爱色精品视频一区二区| 亚洲精品国产中文字幕| 天天做天天爱夜夜爽女人爽| 成在人线AV无码免观看| 亚洲女同精品一区二区久久| 日本高清视频网站www| 亚洲中文字幕无线乱码va| 夜夜嗨久久人成在日日夜夜| 97久久久亚洲综合久久| 人妻av中文字幕无码专区| 亚洲精品久久久中文字幕痴女| 欧美一区二区三区欧美日韩亚洲| 国产成人无码免费视频麻豆| 欧美丝袜高跟鞋一区二区| 韩国精品久久久久久无码| 欧美一区二区人人喊爽| 国产福利深夜在线播放| 亚洲国产精品一区二区久久| 国产精品中文字幕一区| 一区二区日韩中文字幕| 久操热在线视频免费观看| 精品一区二区不卡无码av| av午夜福利亚洲精品福利| 人人妻人人狠人人爽| 国产美女在线观看大长腿| 国产a在视频线精品视频下载| 国产极品美女高潮抽搐免费网站 | 亚洲国产成人AⅤ片在线观看|