2

I am reading this on a man page:

[-n number-to-stat[:max-size[:min-size][:num-directories[:chunk-size]]]]

I interpret this as -n is optional but how do I specify the num-directories?

Preferably I would like to not enter anything for number-to-stat, max-size, min-size and chunk-size, just give a value for num-directories - how do I express that?

3
  • What man page is this from? – cutrightjm Oct 14 '20 at 0:21
  • You may want to add the application name. From searching, is it bonnie++? If so, please add that to your question. – KGIII Oct 14 '20 at 0:54
  • Something's wrong, how can it tell num-directories apart from min-size if one but not both are specified? – Oskar Skog Oct 14 '20 at 4:45
4

The usual convention is that square brackets group things that are optional. You have several levels of nested square brackets to interpret. The square brackets group things like parentheses in math expressions - everything within a set of square brackets must be considered as a single unit.

That entire construct is in square brackets - that means that whole "chunk" is optional - it can be there, or not, as a single unit.

Let's assume that we want it to be there, so let's strip away the outermost level of square brackets, and then we're left with:

-n number-to-stat[:max-size[:min-size][:num-directories[:chunk-size]]]

Which means, if anything at all from the original construct is present, it must start with -n, followed by number-to-stat. Note that number-to-stat is not optional in this case - if -n is there, then it must be followed by a number-to-stat. Everything following that is within yet another group of square brackets, so it too, as a single unit, is optional.

If anything does follow the number-to-stat, it must be in this form:

:max-size[:min-size][:num-directories[:chunk-size]]

Which means that the next part of the expression must be :max-size. That can optionally be followed by a :min-size - or not, as you like... But that by itself is in another grouping of square brackets, so it is a single unit, independent of the rest.

Whether or not :min-size is present, you could also then optionally append :num-directories, and if you do, you could then optionally append :chunk-size to that. If you didn't put a :num-directories, you can't put a :chunk-size, because they're together within a single group of square brackets.

To answer your direct question, if you use the -n option at all, you can't omit the number-to-stat, that is going to be required. You can omit :max-size, but then if you do so, you can't provide :min-size (I know you said you didn't want to anyway). After that, you can give :num-directories, and you can omit the :chunk-size. And, if course, if you don't provide the -n, then you can't provide any of the rest of it.

And, of course, this all is contingent upon the assumption that the example you gave uses the square brackets in the way they're typically used in documentation.

2
  • Do you separate the values with colon? If you want number-to-stat to be 12, max-size 5, min-size to remain at its default value , num-directories to 20 and chunk-size to 25, would you enter -n 12:5::20:25 ? – d-b Oct 14 '20 at 8:01
  • The description (assuming it's meant literally) indicates that the values are to be separated by a colon. – patbarron Oct 14 '20 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.