Linux常用的基本命令cp、mv、rm、cat、find(三) |
您所在的位置:网站首页 › linux显示目录下所有文件 › Linux常用的基本命令cp、mv、rm、cat、find(三) |
一、cp复制文件命令
1、cp file2 /tmp :复制file2文件到/tmp目录下 2、cp /tmp/file2 /home :复制/tmp/file2文件到/home目录下 3、cp /home/file2 /tmp/file3: 复制/home/file2到/tmp目录下并改名为file3 4、cp -p /tmp/file3 /home :复制/tmp/file3到/home目录下并复制文件属性 5、cp -r /dir5 /tmp :复制/dir5目录到/tmp下 二、mv移动文件或目录命令1、mv file4 /tmp :移动file4文件到/tmp目录下 2、mv /home/file3 /tmp: 移动/home/file3文件到/tmp目录下 3、mv /home/file3 /tmp/file5: 移动/home/file3文件到/tmp目录下并改名为file5 4、mv file3 file4 :将file3改名为file4 5、mv dir10 /tmp :移动目录到/tmp下 6、mv dir10 dir11 :讲dir10目录改名为dir11 三、rm删除文件命令1、rm file1 :删除文件file1 2、rm -f file1 :不用确认直接删除file1 3、rm -f file1 file2 file3 :不用确认同时删除多个文件 4、rm /tmp/file1: 删除指定目录/tmp下的文件file1 5、rm fi* :删除以fi开头的文件 6、rm -r dir: 递归的方式删除非空目录dir 7、rm -rf dir :不用确认直接删除非空目录dir 四、cat查看文件内容命令1、cat /etc/passwd :查看/etc/passwd文件 2、cat /etc/passwd |more: 分屏查看文件内容 3、cat /etc/passwd |less: 分屏查看文件内容,可以上下翻页,“q”退出 五、find查找文件命令1、find pass* :在当前目录下查找以pass开头的文件 2、find /etc/pass*: 在/etc目录中查找以pass开头的文件 3、find /etc/pass* -print: 在/etc目录中查找以pass开头的文件,并显示出来 4、find -amin -60:最近60分钟内访问过的文件 5、find -cmin -60:最近60分钟内修改过的文件 6、find ./ -name ‘*.log’:在当前目录下查找后缀为.log的文件 ![]() 或者为: find ./*.txt -exec cp {} ../dir2/3.txt \; 六、grep在文件内容中查找关键字1、grep “rpm” /etc/passwd :在/etc/passwd文件中查找关键字rpm |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |