2013-07-24 1 views
0

나는 다음과 같은 내용이 포함되어있는 파일이 있습니다OpenWrt에서 sh로 정렬 된 파일 내용을 얻는 방법은 무엇입니까?

type1 
type2 
type4 
type15 
type13 
type10 
type9 
type8 
type3 
type5 
type6 
type7 
type11 
type12 
type14 

내가 정렬 된 내용 cat file|sort -u

를 얻기 위해이 명령을 사용을하지만, 나는 다음과 같은 결과가 :

$cat file|sort -u 
type1 
type10 
type11 
type12 
type13 
type14 
type15 
type2 
type3 
type4 
type5 
type6 
type7 
type8 
type9 

무엇입니까 오른쪽 명령을 사용하여 다음 결과를 얻으시겠습니까?

type1 
type2 
type3 
type4 
type5 
type6 
type7 
type8 
type9 
type10 
type11 
type12 
type13 
type14 
type15 

이 내 정렬 명령 도움말 :

[email protected]:~# sort --help 
BusyBox v1.19.2 (2013-05-20 07:23:28 CEST) multi-call binary. 

Usage: sort [-nru] [FILE]... 

Sort lines of text 

     -n  Sort numbers 
     -r  Reverse sort order 
     -u  Suppress duplicate lines 
+0

01, 02, 03, 04 ...로 작동합니다. – avignat

+0

알 겠어,하지만 내 데이터는 위의 형식을 가지고있다. – developer

답변

3

이 그것을 어떻게해야이 :

sort -u -k 1.5n file 

-k 옵션은 정렬 키를 지정합니다. 1.5은 입력의 1 열의 문자 5에서 시작하고 n은 사전 편집 대신 숫자 정렬을 수행해야 함을 의미합니다.

+0

openwrt에서 sh를 사용하고 -k 옵션을 가지고 있지 않다. 내 게시물을 업데이트했다. – developer

+0

당신의 버전은 매우 부족하다. 많은 표준 옵션이 없다. 리눅스이기 때문에 GNU sort를 설치할 수 있어야합니다. – Barmar

0

coreutils-sort 패키지를 사용해보십시오.

opkg install coreutils-sort -force-overwrite 
관련 문제