글
linux shell command: sort
Documents/Linux
2011. 4. 19. 16:48
참조
http://lowfatlinux.com/linux-sort-manual.html
http://www.linux.co.kr/home/bookboard/view.html?id=34&code=linuxcom&start=50&position=
데이타를 다른 scripting language를 이용하지 않고, shell 명령어로 정렬하는 명렁어
http://lowfatlinux.com/linux-sort-manual.html
http://www.linux.co.kr/home/bookboard/view.html?id=34&code=linuxcom&start=50&position=
데이타를 다른 scripting language를 이용하지 않고, shell 명령어로 정렬하는 명렁어
test .txt
-------------
1 5 9
2 7 15
7 9 12
-------------
# sort -n -k 3 test
-n : 데이터를 숫자로 인식한 채로 비교해서 정렬
-k 숫자 : 해당 숫자의 열의 데이타로 정렬
-r : 내림차순으로 정렬 (default는 오름차순임)
결과
------------
1 5 9
7 9 12
2 7 15
------------
-------------
1 5 9
2 7 15
7 9 12
-------------
# sort -n -k 3 test
-n : 데이터를 숫자로 인식한 채로 비교해서 정렬
-k 숫자 : 해당 숫자의 열의 데이타로 정렬
-r : 내림차순으로 정렬 (default는 오름차순임)
결과
------------
1 5 9
7 9 12
2 7 15
------------