Home | Mirror | Search

15. sort - sort lines of text files

$ du -s * | sort -k1,1rn
	
$ rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n
$ dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
	

15.1. 對列排序

# sort -t ':' -k 1 /etc/passwd
		
ort -n -t ‘ ‘ -k 2 file.txt
		

多列排序

$ sort -n -t ‘ ‘ -k 2 -k 3 file.txt
		
comments powered by Disqus