답변:
을 사용하여 coreutils를 설치할 수 있습니다 brew install coreutils
.
shuf
로 연결됩니다 gshuf
. coreutils를 설치할 때주의 사항을 읽으십시오.
brew install coreutils
g
osx에 기본적으로 접두사 를 사용 하여 utils를 설치하므로 위 명령을 사용하여 설치할 수 있습니다.
또 다른 해결책은 공급 업체가 제공 한 도구에 대해 배우는 것입니다. 물론 당신이 할 수 체인 jot
, paste
, sort
, cut
, head
와 같은 결과를 얻을 수 있습니다.
jot -r "$(wc -l FILE)" 1 |
paste - FILE |
sort -n |
cut -f 2- |
head -n 10
jot
전에 들어 본 적이 없다 . 지식을 넓혀 주셔서 감사합니다.
Macports를 사용하여 coreutils를 다음과 같이 설치할 수 있습니다
sudo port install coreutils
이것은 GNU 핵심 유틸리티를 / opt / local / bin에 넣고 ag를 붙입니다.
e, g gshuf
다른 옵션은 randomize-lines
shuf rl
와 비슷한 기능을 가진 명령 이있는 (homebrew) 패키지 를 설치 하는 것 입니다.
Usage: rl [OPTION]... [FILE]...
Randomize the lines of a file (or stdin).
-c, --count=N select N lines from the file
-r, --reselect lines may be selected multiple times
-o, --output=FILE
send output to file
-d, --delimiter=DELIM
specify line delimiter (one character)
-0, --null set line delimiter to null character
(useful with find -print0)
-n, --line-number
print line number with output lines
-q, --quiet, --silent
do not output any errors or warnings
-h, --help display this help and exit
-V, --version output version information and exit