移动文件或目录的命令 mv

Thursday, September 18th, 2008 | SEO技术

mv 命令是用来移动文件或目录的;有以下几种格式;

#mv file1 file2 注:把file1移动到file2,如果file2不存在,则创建file2文件名;
#mv file1 dir 注:把一个文件移动到一个事实存在的目录;
#mv dir1 dir2 移动目录dir1 到 dir2 ,如果dir2不存在,则创建它;
#mv file1 file2 file3 … … dir 移动file1、file2、file3等多个文件到dir目录中;
#mv dir1 dir2 … … dirn 注:移动目录dir1和dir2等多个目录到dirn目录中

参数-i ,表示人机交互模式;提示警告信息;

举例:

[root@localhost ~]# mv -i 123.txt 234.txt
mv:是否覆盖“234.txt”? y 注:要在这里输入y,表示允许覆盖234.txt文件;如果是n,请示不允许;

mv 也能和通配符结合一起使用,这样能把相似特征的文件移动到某处;

* 代表0个或多个字符
[]内部包括任何字符
? 任何单个字符

举例:比如移动以数字开头的文件或目录到 root目录下的tmp目录中;

[root@localhost ~]# pwd
/root
[root@localhost ~]# mv [0-9]* tmp/
[root@localhost ~]# ls -lh tmp/
总计 4.0K
-rw-r–r– 1 root root 21 04-19 15:06 234.txt
-rw-r–r– 1 root root 0 04-19 22:23 2kexe.txt
-rw-r–r– 1 root root 0 04-19 22:25 333.tot
-rw-r–r– 1 root root 0 04-19 22:23 6mns.doc

Related posts

Tags:

No comments yet.

Leave a comment

You must be logged in to post a comment.

加入收藏 本地收藏 百度搜藏 QQ书签 美味书签 Google书签 Mister Wong

Search

友情链接