The portable syntax requires -n
if you want to specify an increment. When in doubt, use nice -n
.
In nice -15
the argument is not really a negative number. It is a dash concatenated with a positive number. The leading dash indicates it is an option. Compare this e.g. to kill -15
which is equivalent to kill -s 15
. Similarly nice -15
is equivalent to nice -n 15
.
kill -15
is not as confusing as nice -15
, because you don't expect signal numbers to be negative. In the case of nice
you were confused because an adjustment to niceness may be negative and <dash><digit(s)> surely looks like a non-positive number. It's easy to interpret -15
as "minus fifteen" in cases where negative numbers make sense.
Note the number after the dash may be with an explicit sign:
nice -+15 nice # prints 15
sudo nice --15 nice # prints -15
Unfortunately --15
looks kinda like a long option (compare: --help
) with a positive number, this may add to the confusion. It is another reason to prefer nice -n
.