linux命令行【五】磁盘操作
磁盘操作可以学到什么?
磁盘一些目录文件的操作可以查看文件系统的大小,并且按照大小进行排序操作。
-
df -h
查看挂载分区 -
ls -lSr |more
根据大小对文件和目录进行排序 -
du -sh dir1
查看目录大小 -
du -sh * | sort -rn
查看文件大小并对文件和目录进行排序 -
rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n
查看安装的 rpm 包并按照正向排序
关于 sort 命令的选项
-b, --ignore-leading-blanks ignore leading blanks
-d, --dictionary-order consider only blanks and alphanumeric characters
-f, --ignore-case fold lower case to upper case characters
-g, --general-numeric-sort compare according to general numerical value
-i, --ignore-nonprinting consider only printable characters
-M, --month-sort compare (unknown) < `JAN' < ... < `DEC'
-n, --numeric-sort compare according to string numerical value
-r, --reverse reverse the result of comparisons`
Other options:
-c, --check check whether input is sorted; do not sort
-k, --key=POS1[,POS2] start a key at POS1, end it at POS2 (origin 1)
-m, --merge merge already sorted files; do not sort
-o, --output=FILE write result to FILE instead of standard output
-s, --stable stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE use SIZE for main memory buffer
-t, --field-separator=SEP use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or/tmp;
multiple options specify multiple directories
-u, --unique with -c, check for strict ordering;
without -c, output only the first of an equal run
-z, --zero-terminated end lines with 0 byte, not newline
--help 显示此帮助信息并退出
--version 输出版本号信息并退出
Copyright © 2018 Powered by ANDY