Given an array of similar hosts, what are some of the advantages and disadvantages of zero padding or not?

Zero Padding


No Padding


I've seen both in practice and have heard reasons for/against each. The only snippet I've come across referencing zero padding is a small note in the Debian addclients manpage, but no reasoning: "Padding hostnames with zeros is not recommended." Does anyone know what background or justification might be behind this recommendation?


  • Simple alphanumeric sorting
  • Fixed width


  • Breaks down after the maximum padded id (99, 999, ...)
  • Adds slight complexity to any comparison/validation (^\w+-\d{<id_length>}$ vs ^\w+-\d+$)
  • 5
    This is pure opinion.
    – John
    Jun 18, 2014 at 17:44
  • 3
    This is purely opinion-based, as asked, but I think it's a good question, nonetheless... perhaps if you change it to ask about the advantages and disadvantages of each approach (and maybe why Debian's docs advise against 0-padding), it would stay open, and allow some useful insight/answers. Jun 18, 2014 at 17:46
  • 3
    I think this is a subjective question, however this is an ongoing discussion in meta. The good thing is that this OP, being new, did at least some research on the matter before coming here, and the question is relevant to professional system administration.
    – MDMoore313
    Jun 18, 2014 at 17:56

1 Answer 1


FWIW, we pad for consistency. That way we know that $hostname always has $x digits, so it saves a step. And saving 1 step on 3,000 machines goes a long way (about 1.5 miles, to be exact).

Of course, let's look at both sides. The Pros? For me it was discussed above. Host name consistency, and some people (myself included) enjoy looking at rows upon rows of host names that are all the same length, since I'm in charge of configuration here and all those machines with the exact same name are the exact same length in my spreadsheet and have the exact same configuration in real life. Ahh, what a relief.

The cons? The only one I can think of is that you make the padding too small, for instance padding 2 zeros and you wind up with over 100 hosts. What do you do? Forget about it? Rename the first 99 hosts? Making the padding too large really has no harm I can see, other than being able to use that space for something else (site code, workstation code, etc.).

Yes, in the end it's entirely up to you, but I think the votes on this answer will give the general community consensus, up or down.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .