tags:

views:

104

answers:

1

GNU xargs has option '-x'. The man page says:

-x Exit if the size (see the -s option) is exceeded.

But xargs seems to not care if -x is set or not. I have been unable to make an example in which the -x has any effect at all.

Please provide two examples in which the only difference is an added -x and that produce different output.

+3  A: 

You have to set a size to test whether you've exceeded it.

$ echo -e "12\n1234"
12
1234
$ echo -e "12\n1234" | xargs echo
12 1234
$ echo -e "12\n1234" | xargs  -x echo        # no effect
12 1234
$ echo -e "12\n1234" | xargs -s 8 echo       # error and continue
xargs: argument line too long
12
$ echo -e "12\n1234" | xargs -s 8 -x echo    # error and exit
xargs: argument line too long
Dennis Williamson
You example shows the difference. However, I still cannot explain why this gives 1 - 11: `(seq 11; echo -e "1234111";seq 12 15) | xargs -s 11 echo`but this gives 1 - 9: `(seq 11; echo -e "1234111";seq 12 15) | xargs -s 11 -x echo`Will `-x` always only give a difference of one single line (namely the line that would have been too long)? I had sort of expected 12 - 15 to be in one of them.
Ole Tange