Linux实用代码--文件系统操作
? ?? ?NO7. 为了查找当前文件系统中的所有目录并排序
? ?? ?? ???[root@rehat root]# find . -type d | sort
? ?? ?NO8. 为了查找系统中所有的rmt磁带设备
? ?? ?? ???[root@rehat root]# find /dev/rmt
??17. 显示文件/文件夹清单
? ?? ?ls / dir
? ?? ?NO1. 显示所有文件,包括以.开头的隐含文件
? ?? ?? ???[root@rehat root]# ls -a
? ?? ?NO2. 显示文件的详细信息
? ?? ?? ???[root@rehat root]# ls -l
? ?? ?NO3. 显示当前目录及所有子目录信息
? ?? ?? ???[root@rehat root]# ls -Rl
? ?? ?NO4. 以时间排序显示目录,这在找最新文件有用
? ?? ?? ???[root@rehat root]# ls -tl
? ?? ?NO5. 以文件大小排序
? ?? ?? ???[root@rehat root]# ls -Sl
? ?? ?NO6. 显示文件大小,并按大小排序
? ?? ?? ???[root@rehat root]# ls -s -l -S
??18. 移动或更改文件/文件夹名称
? ?? ?mv 与 cp命令用法相似
? ?? ?NO1. 若移动目标文件已存在,要在移动之前,先备份原来的目录文件
? ?? ?? ???[root@rehat root]# mv -b test.txt test2/
? ?? ?? ???这样在 test2 下将有两个文件 test.txt 及 text.txt~
? ?? ?? ???其中 test.txt~ 是备份文件,test.txt是新的文件
? ?? ?NO2. 若移动目标文件已存在,但不想弹出是否覆盖的提示,直接覆盖
? ?? ?? ???[root@rehat root]# mv -f test.txt test2/
? ?? ?NO3. 当源与目标都拥有同一个文件,若源文件比目标新则移动,否则不移动
? ?? ?? ???[root@rehat root]# mv -u test.txt test2/
? ?? ?NO4. 更改文件名称
? ?? ?? ???[root@rehat root]# mv test.txt test2.txt
? ?? ?NO5. 更改目录名称
??
? ?? ?? ???[root@rehat root]# mv /test2 /test2_2