mv

移动或重命名文件或目录.

语法

  mv [options]... Source Dest

  mv [options]... Source... Directory

选项



-b
--backup
     备份每个文件,否则会被覆盖或删除

-f
--force
     删除现有的目标文件,永远不要提示用户

-i
--interactive
     提示是否覆盖每个现有目标文件,而不管其权限如何。
     如果响应不是以“y”或“Y”开头,则跳过该文件。

-S SUFFIX
--suffix=SUFFIX
     将后缀添加到用' -b'组成的每个备份文件。
     备份后缀是~,除非设置为SIMPLE_BACKUP_SUFFIX

-u
--update
     当源文件比目标文件新或者目标文件不存在时,才执行移动操作

-v
--verbose
      在移动之前打印每个文件的名称

-V METHOD
--version-control=METHOD'
       更改使用`-b'进行的备份类型。方法可以是:
     
       t, numbered     使编号的备份
       nil, existing   如果存在编号备份,则进行编号
       never, simple   总是做简单的备份

 --help                   显示帮助和退出
 --version                输出版本信息并退出


例子

将apple重命名为orange.doc:

$ mv apple orange.doc

移动orange.doc 到 Documents 目录:

$ mv orange.doc ~/Documents/orange.doc

将一堆.txt文件扩展名重命名为* .htm

for f in *.txt; do mv ./"$f" "${f%txt}htm"; done

将以’copy.txt’结尾的文件重命名为.txt

for f in *copy.html; do mv "$f" "${f/copy.txt/.txt}";done

mv 命令实例:

linux命令:mv filename.{old,new} filename.{old,new} mv mv filename.{old,new}rootopen.com
linux命令:mv filename.{old,new} filename.{old,new} mv mv filename.{old,new}rootopen.com
2018-04-08 21:37:48

linux命令:mv file_name.extension .. .. file_name.extension mv mv file_name.extension ..rootopen.com
linux命令:mv file_name.extension .. .. file_name.extension mv mv file_name.extension ..rootopen.com
2018-05-14 02:40:48

linux命令:mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> -DgeneratePom=true -DgeneratePom=true -Dpackaging=<packaging> -Dversion=<version> -DartifactId=<artifact-id> -DgroupId=<group-id> -Dfile=<path-to-file> install:install-file mvn mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> -DgeneratePom=truerootopen.com
linux命令:mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> -DgeneratePom=true -DgeneratePom=true -Dpackaging=<packaging> -Dversion=<version> -DartifactId=<artifact-id> -DgroupId=<group-id> -Dfile=<path-to-file> install:install-file mvn mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> -DgeneratePom=truerootopen.com
2018-04-09 11:47:48

linux命令:mv `find .zip ./` . . ./` .zip `find mv mv `find .zip ./` .rootopen.com
linux命令:mv `find .zip ./` . . ./` .zip `find mv mv `find .zip ./` .rootopen.com
2018-04-06 23:56:48

linux命令:mvn deploy:deploy-file -DgroupId=groupId -DartifactId=artifactId -Dversion=1.0 -Dpackaging=jar -Dfile=pathtolib -DrepositoryId=repository -Durl=url -Durl=url -DrepositoryId=repository -Dfile=pathtolib -Dpackaging=jar -Dversion=1.0 -DartifactId=artifactId -DgroupId=groupId deploy:deploy-file mvn mvn deploy:deploy-file -DgroupId=groupId -DartifactId=artifactId -Dversion=1.0 -Dpackaging=jar -Dfile=pathtolib -DrepositoryId=repository -Durl=urlrootopen.com
linux命令:mvn deploy:deploy-file -DgroupId=groupId -DartifactId=artifactId -Dversion=1.0 -Dpackaging=jar -Dfile=pathtolib -DrepositoryId=repository -Durl=url -Durl=url -DrepositoryId=repository -Dfile=pathtolib -Dpackaging=jar -Dversion=1.0 -DartifactId=artifactId -DgroupId=groupId deploy:deploy-file mvn mvn deploy:deploy-file -DgroupId=groupId -DartifactId=artifactId -Dversion=1.0 -Dpackaging=jar -Dfile=pathtolib -DrepositoryId=repository -Durl=urlrootopen.com
2018-02-10 04:22:48

linux命令:mvn archetype:create -DgroupId=my.work -DartifactId=MyProject -DartifactId=MyProject -DgroupId=my.work archetype:create mvn mvn archetype:create -DgroupId=my.work -DartifactId=MyProjectrootopen.com
linux命令:mvn archetype:create -DgroupId=my.work -DartifactId=MyProject -DartifactId=MyProject -DgroupId=my.work archetype:create mvn mvn archetype:create -DgroupId=my.work -DartifactId=MyProjectrootopen.com
2018-04-18 09:39:48

linux命令:mvn -Dmaven.test.skip=true install install -Dmaven.test.skip=true mvn mvn -Dmaven.test.skip=true installrootopen.com
linux命令:mvn -Dmaven.test.skip=true install install -Dmaven.test.skip=true mvn mvn -Dmaven.test.skip=true installrootopen.com
2017-12-29 18:27:48

linux命令:mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo eclipse:add-maven-repo -Declipse.workspace=<path-to-eclipse-workspace> mvn mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-reporootopen.com
linux命令:mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo eclipse:add-maven-repo -Declipse.workspace=<path-to-eclipse-workspace> mvn mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-reporootopen.com
2018-04-09 02:51:48

linux命令:mv $1 $2 && ln -s $2/$(basename $1) $(dirname $1) $1) $(dirname $1) $2/$(basename -s ln && $2 $1 mv mv $1 $2 && ln -s $2/$(basename $1) $(dirname $1)rootopen.com
linux命令:mv $1 $2 && ln -s $2/$(basename $1) $(dirname $1) $1) $(dirname $1) $2/$(basename -s ln && $2 $1 mv mv $1 $2 && ln -s $2/$(basename $1) $(dirname $1)rootopen.com
2018-05-21 07:55:48

linux命令:mv -vi file{,~} file{,~} -vi mv mv -vi file{,~}rootopen.com
linux命令:mv -vi file{,~} file{,~} -vi mv mv -vi file{,~}rootopen.com
2018-03-25 07:46:48

linux命令:mv ubuntu-10.04-rc-desktop-amd64.iso ubuntu-10.04-desktop-amd64.iso; i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; while true; do if wget $i; then zsync $i; date; break; else sleep 30; fi; done done fi; 30; sleep else break; date; $i; zsync then $i; wget if do true; while i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; ubuntu-10.04-desktop-amd64.iso; ubuntu-10.04-rc-desktop-amd64.iso mv mv ubuntu-10.04-rc-desktop-amd64.iso ubuntu-10.04-desktop-amd64.iso; i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; while true; do if wget $i; then zsync $i; date; break; else sleep 30; fi; donerootopen.com
linux命令:mv ubuntu-10.04-rc-desktop-amd64.iso ubuntu-10.04-desktop-amd64.iso; i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; while true; do if wget $i; then zsync $i; date; break; else sleep 30; fi; done done fi; 30; sleep else break; date; $i; zsync then $i; wget if do true; while i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; ubuntu-10.04-desktop-amd64.iso; ubuntu-10.04-rc-desktop-amd64.iso mv mv ubuntu-10.04-rc-desktop-amd64.iso ubuntu-10.04-desktop-amd64.iso; i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; while true; do if wget $i; then zsync $i; date; break; else sleep 30; fi; donerootopen.com
2018-02-11 00:02:48

linux命令:mv * .[0-9a-Z]* ../; cd ..; rm -r $OLDPWD $OLDPWD -r rm ..; cd ../; .[0-9a-Z]* * mv mv * .[0-9a-Z]* ../; cd ..; rm -r $OLDPWDrootopen.com
linux命令:mv * .[0-9a-Z]* ../; cd ..; rm -r $OLDPWD $OLDPWD -r rm ..; cd ../; .[0-9a-Z]* * mv mv * .[0-9a-Z]* ../; cd ..; rm -r $OLDPWDrootopen.com
2018-01-12 21:18:48

linux命令:mv -n * ../; cd ..; rmdir $OLDPWD $OLDPWD rmdir ..; cd ../; * -n mv mv -n * ../; cd ..; rmdir $OLDPWDrootopen.com
linux命令:mv -n * ../; cd ..; rmdir $OLDPWD $OLDPWD rmdir ..; cd ../; * -n mv mv -n * ../; cd ..; rmdir $OLDPWDrootopen.com
2018-04-11 10:24:48

linux命令:mv ./-filename filename filename ./-filename mv mv ./-filename filenamerootopen.com
linux命令:mv ./-filename filename filename ./-filename mv mv ./-filename filenamerootopen.com
2018-01-24 22:00:48

linux命令:mv -- -filename filename filename -filename -- mv mv -- -filename filenamerootopen.com
linux命令:mv -- -filename filename filename -filename -- mv mv -- -filename filenamerootopen.com
2018-05-18 01:05:48

linux命令:mv -i something.conf{,~} && sed "/regexp/s/^/#/" < something.conf~ > something.conf something.conf > something.conf~ < "/regexp/s/^/#/" sed && something.conf{,~} -i mv mv -i something.conf{,~} && sed "/regexp/s/^/#/" < something.conf~ > something.confrootopen.com
linux命令:mv -i something.conf{,~} && sed "/regexp/s/^/#/" < something.conf~ > something.conf something.conf > something.conf~ < "/regexp/s/^/#/" sed && something.conf{,~} -i mv mv -i something.conf{,~} && sed "/regexp/s/^/#/" < something.conf~ > something.confrootopen.com
2018-04-30 07:12:48

linux命令:mv .git .. && rm -rf * && mv ../.git . && mv .git/* . && rmdir .git && git config --bool core.bare true true core.bare --bool config git && .git rmdir && . .git/* mv && . ../.git mv && * -rf rm && .. .git mv mv .git .. && rm -rf * && mv ../.git . && mv .git/* . && rmdir .git && git config --bool core.bare truerootopen.com
linux命令:mv .git .. && rm -rf * && mv ../.git . && mv .git/* . && rmdir .git && git config --bool core.bare true true core.bare --bool config git && .git rmdir && . .git/* mv && . ../.git mv && * -rf rm && .. .git mv mv .git .. && rm -rf * && mv ../.git . && mv .git/* . && rmdir .git && git config --bool core.bare truerootopen.com
2018-01-15 13:36:48

linux命令:mv file.png $( mktemp -u | cut -d'.' -f2 ).png ).png -f2 -d'.' cut | -u mktemp $( file.png mv mv file.png $( mktemp -u | cut -d'.' -f2 ).pngrootopen.com
linux命令:mv file.png $( mktemp -u | cut -d'.' -f2 ).png ).png -f2 -d'.' cut | -u mktemp $( file.png mv mv file.png $( mktemp -u | cut -d'.' -f2 ).pngrootopen.com
2018-02-22 08:39:48

linux命令:mv -b old_file_name new_and_already_existent_file_name new_and_already_existent_file_name old_file_name -b mv mv -b old_file_name new_and_already_existent_file_namerootopen.com
linux命令:mv -b old_file_name new_and_already_existent_file_name new_and_already_existent_file_name old_file_name -b mv mv -b old_file_name new_and_already_existent_file_namerootopen.com
2018-04-22 01:30:48

linux命令:mv public_html{,~~} && mv public_html{~,} && mv public_html{~~,~} public_html{~~,~} mv && public_html{~,} mv && public_html{,~~} mv mv public_html{,~~} && mv public_html{~,} && mv public_html{~~,~}rootopen.com
linux命令:mv public_html{,~~} && mv public_html{~,} && mv public_html{~~,~} public_html{~~,~} mv && public_html{~,} mv && public_html{,~~} mv mv public_html{,~~} && mv public_html{~,} && mv public_html{~~,~}rootopen.com
2018-02-07 14:14:48

linux命令:mv data.{json,yaml} data.{json,yaml} mv mv data.{json,yaml}rootopen.com
linux命令:mv data.{json,yaml} data.{json,yaml} mv mv data.{json,yaml}rootopen.com
2018-01-18 09:10:48

linux命令:mv /etc/fstab /etc/fstab.old && mount | awk '{print $1, $3, $5, $6}'| sed s/\(//g|sed s/\)/' 0 0'/g >> /etc/fstab /etc/fstab >> 0'/g 0 s/\)/' s/\(//g|sed sed $6}'| $5, $3, $1, '{print awk | mount && /etc/fstab.old /etc/fstab mv mv /etc/fstab /etc/fstab.old && mount | awk '{print $1, $3, $5, $6}'| sed s/\(//g|sed s/\)/' 0 0'/g >> /etc/fstabrootopen.com
linux命令:mv /etc/fstab /etc/fstab.old && mount | awk '{print $1, $3, $5, $6}'| sed s/\(//g|sed s/\)/' 0 0'/g >> /etc/fstab /etc/fstab >> 0'/g 0 s/\)/' s/\(//g|sed sed $6}'| $5, $3, $1, '{print awk | mount && /etc/fstab.old /etc/fstab mv mv /etc/fstab /etc/fstab.old && mount | awk '{print $1, $3, $5, $6}'| sed s/\(//g|sed s/\)/' 0 0'/g >> /etc/fstabrootopen.com
2018-05-08 22:59:48

linux命令:mv -iv $FILENAME{,.$(stat -c %y $FILENAME | awk '{print $1}')} $1}')} '{print awk | $FILENAME %y -c $FILENAME{,.$(stat -iv mv mv -iv $FILENAME{,.$(stat -c %y $FILENAME | awk '{print $1}')}rootopen.com
linux命令:mv -iv $FILENAME{,.$(stat -c %y $FILENAME | awk '{print $1}')} $1}')} '{print awk | $FILENAME %y -c $FILENAME{,.$(stat -iv mv mv -iv $FILENAME{,.$(stat -c %y $FILENAME | awk '{print $1}')}rootopen.com
2018-02-15 02:00:48

linux命令:mv -iv $FILENAME{,.$(stat -c %Z $FILENAME)} $FILENAME)} %Z -c $FILENAME{,.$(stat -iv mv mv -iv $FILENAME{,.$(stat -c %Z $FILENAME)}rootopen.com
linux命令:mv -iv $FILENAME{,.$(stat -c %Z $FILENAME)} $FILENAME)} %Z -c $FILENAME{,.$(stat -iv mv mv -iv $FILENAME{,.$(stat -c %Z $FILENAME)}rootopen.com
2018-04-28 08:23:48

linux命令:mv ~/html/*~ ~ ~ ~/html/*~ mv mv ~/html/*~ ~rootopen.com
linux命令:mv ~/html/*~ ~ ~ ~/html/*~ mv mv ~/html/*~ ~rootopen.com
2018-03-25 13:22:48

linux命令:mv filename{,.old} filename{,.old} mv mv filename{,.old}rootopen.com
linux命令:mv filename{,.old} filename{,.old} mv mv filename{,.old}rootopen.com
2018-01-08 20:02:48

Linux的Bash命令行(A-Z排序)