Linux命令---- mv移动或重命名文件/目录
2017-05-28 15:34
645 查看
Linux 下查看帮助说明,可以用mv –help或man mv, 永远是最快捷的方式
mv 的最后一个目标文件一定是目录,除非用 -t 参数先指定了目录。
1、移动一文件夹(目录及目录下的所有文件)到另一目录
下面案例是为了保存已下载代码的.repo文件夹并移到另一个目录中, 已后下载基于现有的来下载。
再看一案例,移动已下载的MSM8953文件到work工作目录
2、移动一文件或多个文件到目录
3、重命名文件
目录也可以重命名跟重命名文件一样。
@ubuntu:~$ mv --help Usage: mv [OPTION]... [-T] SOURCE DEST or: mv [OPTION]... SOURCE... DIRECTORY or: mv [OPTION]... -t DIRECTORY SOURCE... Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. --backup[=CONTROL] make a backup of each existing destination file -b like --backup but does not accept an argument -f, --force do not prompt before overwriting -i, --interactive prompt before overwrite -n, --no-clobber do not overwrite an existing file If you specify more than one of -i, -f, -n, only the final one takes effect. --strip-trailing-slashes remove any trailing slashes from each SOURCE argument -S, --suffix=SUFFIX override the usual backup 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 4000 file is missing -v, --verbose explain what is being done -Z, --context set SELinux security context of destination file to default type --help display this help and exit --version output version information and exit 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 never make backups (even if --backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Full documentation at: <http://www.gnu.org/software/coreutils/mv> or available locally via: info '(coreutils) mv invocation'
mv 的最后一个目标文件一定是目录,除非用 -t 参数先指定了目录。
1、移动一文件夹(目录及目录下的所有文件)到另一目录
下面案例是为了保存已下载代码的.repo文件夹并移到另一个目录中, 已后下载基于现有的来下载。
@ubuntu:~$ mv MSM8953/.repo/ work/MSM8909/ @ubuntu:~$ ls -a MSM8953/ . build device libcore platform_testing tools .. build.sh docs libnativehelper prebuilts vendor abi cts external Makefile sdk art dalvik frameworks ndk shortcut-fe bionic developers hardware packages system bootable development kernel pdk toolchain @ubuntu:~/work$ cd MSM8909/ @ubuntu:~/work/MSM8909$ ls -a . .. .repo
再看一案例,移动已下载的MSM8953文件到work工作目录
@ubuntu:~$ ls bin Documents examples.desktop Music Public Templates work Desktop Downloads MSM8953 Pictures repo Videos @ubuntu:~$ mv MSM8953/ work/ @ubuntu:~$ ls bin Documents examples.desktop Pictures repo Videos Desktop Downloads Music Public Templates work @ubuntu:~$ cd work @ubuntu:~/work$ ls MSM8909 MSM8953
2、移动一文件或多个文件到目录
@ubuntu:~/work$ ls directory MSM8909 MSM8953 test @ubuntu:~/work$ mv test directory/ @ubuntu:~/work$ ls directory MSM8909 MSM8953 @ubuntu:~/work$ ls directory/ test
@ubuntu:~/work$ ls directory MSM8909 MSM8953 test1 test2 @ubuntu:~/work$ mv test1 test2 directory/ @ubuntu:~/work$ ls directory/ test test1 test2
3、重命名文件
@ubuntu:~/work/directory$ ls test test1 test2 @ubuntu:~/work/directory$ mv test test3 @ubuntu:~/work/directory$ ls test1 test2 test3
目录也可以重命名跟重命名文件一样。
相关文章推荐
- Linux命令:cp 命令--创建文件和目录的副本 mv命令--移动或重命名文件/目录
- Linux 移动或重命名文件/目录---mv命令
- 我使用过的Linux命令之mv - 文件或目录改名、移动位置
- Linux命令:目录重命名与移动mv,删除文件rm,目录创建mkdir删除rmdir,查看file,cat,more,tail,head
- Linux 移动或重命名文件/目录-mv 的10个实用例子
- Linux 命令 - mv: 移动或重命名文件
- Linux命令 find和mv的结合使用:查找文件,移动到某个目录
- 【每天一个Linux命令】24. 移动文件(重命名)命令mv
- Linux命令 find和mv的结合使用:查找文件,移动到某个目录
- Linux移动文件与目录-mv命令的10个实用例子
- Linux文件操作详解(九)--文件/文件夹的重命名和移动(mv命令)
- 【Unix/Linux】【命令】【文件,目录操作工具】移动,重命名文件,目录——mv命令
- Linux命令之目录切换、创建/删除/复制/移动文件 - cd,mkdir,cp,mv,rmdir,rm
- Linux 移动或重命名文件/目录-mv 的10个实用例子
- 我使用过的Linux命令之mv - 文件或目录改名、移动位置
- Linux 移动或重命名文件/目录-mv 的10个实用例子
- 一天一个Linux基础命令之切换目录移动命令mv
- Linux命令移动文件、目录
- Linux mv --文件或目录改名,移动位置
- linux命令学习-文件目录之mv命令