Bash迭代当前文件夹html
ls---list information about the FILES(the current directory by default)[du也统计文件大小,可是du使用的是tree的数据结构,ls则是数组的数据结构]shell
ls -author #罗列文件信息包含做者 ls -c -lt #根据访问时间倒序排列 ls -c #list entries by columns ls -d #list directory entries instead of contents and don't dereference symbolic links ls -l -h # print sizes in human readable format
ls -l ./ceshi/ceshi #罗列第三级文件夹ceshi
Bash迭代文件夹树express
tree命令数组
Bash建立文件夹数据结构
mkdir---make directoryes测试
-p---no error if existing,make parent directories as needed(带着-p参数,会自动判断只有当文件夹不存在的时候才建立,能够建立多层次目录)lua
mkdir newdir #第一次建立不存在的目录newdir成功 mkdir newdir #第二次建立已经存在的newdir失败 mkdir -p newdir#成功 mkdir -p newdir/firse/second/thired/#能够一次建立多级目录
mkdir能够建立一个完整的项目目录结构spa
mkdir -p project/{lib/ext,bin,src/doc/{html,info,pdf},demo/stat}#执行完成后,当前目录下后出现一个当前结构【原文借鉴】
Bash删除文件和文件夹code
rm---rm removes each specified file.By default ,it does not remove directories.orm
-i---prompt before ervry removal
-r---remove directories and their contents recursively.
rm -i -r project#删除文件夹project和文件夹下的所有内容
Bash查找搜索文件夹
find---find searches the directory tree rooted at each given file name by evaluating the given expression from left to right,according to the rules of percedence,util the outcome is known,at which point find moves on to the next file name.(在目录树上搜索结果)
-name---Base of file name matches shell pattern pattern.(根据文件名字匹配搜索)【详细用法参考】
find './软件' -name '*.txt' #查找当前目录下的软件文件夹下,全部以txt结尾的文件 find '.' -user harvey#查找属于用户harvey的文件 find '.' -mtime -1#一天之内修改的文件 find '.' -ctime -1#一天之内建立的文件 find '.' -ctime -1 -name '*.txt'#今天建立的文本文件 find . -size +1000000c #查找文件大于1M的文件
Bash统计文件夹下全部文件的大小
du---summarize disk usage of each FILE,recursively for directories(递归的统计磁盘的使用状况)
-h---print sizes in human readable format(e.g.,1k 234M 2G)
du -h '.' #统计当前文件夹下各文件使用磁盘的状况
Bash移动文件
mv---Rename SOURCE to DEST or move SOURCE(s) to DIRECTOR.
mv test.txt x.txt #当前目录下的test.txt重命名为x.txt mv x.txt ./ceshi/x.txt #移动x.txt到测试文件夹下
Bash复制文件
cp kkkk.txt k1.txt # 在当前文件夹下复制文件 cp kkkk.txt ./ceshi/k2.txt #复制文件到新的文件夹