标签:style blog io color os for sp 文件 div
首先我们通过man 来看看 ls其中有几项;
--sort=WORD
sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v--time=WORD
with -l, show time as WORD instead of modification time: atime -u, access -u, use -u, ctime -c, or status -c; use specified time as sort key if --sort=time--time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like ‘date’; if FORMAT is FORMAT1<newline>FORMAT2, FORMAT1
applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with ‘posix-’, STYLE takes effect only outside the POSIX locale
ls -lS 按大小降序
ls -l | sort -n -k5 按大小升序 ls -lrt 按时间降序 ls -lnt 按时间升序 ls -l | sort -k9 按文件名升序(这是ls的默认输出方式) ls -lr 按文件名降序
ls -l | sort -rk9 按文件名降序
附:
ls对当前目录和文件大小排序
du -s * | sort -nr
只对当前目录排序,并用直观的大小显示出来
for i in $(ls -l |grep ‘^d‘ |du -s * |sort -nr|awk ‘{print $2}‘);do du -sh $i;done
标签:style blog io color os for sp 文件 div
原文地址:http://www.cnblogs.com/mjorcen/p/4075610.html