![SmartOS(SunOS)에서 "xargs -n"이 다른 구현과 다르게 동작하는 이유는 무엇입니까?](https://linux55.com/image/142821/SmartOS(SunOS)%EC%97%90%EC%84%9C%20%22xargs%20-n%22%EC%9D%B4%20%EB%8B%A4%EB%A5%B8%20%EA%B5%AC%ED%98%84%EA%B3%BC%20%EB%8B%A4%EB%A5%B4%EA%B2%8C%20%EB%8F%99%EC%9E%91%ED%95%98%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
-n
SmartOS(Solaris인 것 같습니다)에 있는 xargs 옵션은 제가 만난 다른 버전의 xargs와 다르게 동작하는 것 같습니다 .
예를 들어:
내장 /usr/bin/xargs(이상한 동작):
# printf 'one\0two\0three' | xargs -0 -I{} -n 1 echo "- {}"
- {} one
- {} two
- {} three
GNU Findutils /opt/local/bin/xargs(예상 동작):
# printf 'one\0two\0three' | /opt/local/bin/xargs -0 -I{} -n 1 echo "- {}"
- one
- two
- three
MacOS, NetBSD 및 CentOS의 Xargs는 모두 이전 예제와 동일하게 동작합니다. SmartOS xargs는 어떻게 다릅니까?
SmartOS xargs 맨페이지에서:
-n number
Invokes utility using as many standard input arguments
as possible, up to number (a positive decimal integer)
arguments maximum. Fewer arguments are used if:
o The command line length accumulated exceeds
the size specified by the -s option (or
{LINE_MAX} if there is no -s option), or
o The last iteration has fewer than number, but
not zero, operands remaining.
Gnu Findutils xargs 맨페이지에서:
-n max-args, --max-args=max-args
Use at most max-args arguments per command line. Fewer than max-args arguments will be used if the size (see the -s option) is exceeded, un‐
less the -x option is given, in which case xargs will exit.
쉘 스크립트를 이식할 때 이러한 차이점을 발견했는데 왜 동작이 다른지 아는 사람이 있는지 궁금합니다.