Alex Rivera | Logout

Limit on file name length in bash

Asked 2011-07-04T12:24:08.867
85

The following questions are meant for bash and linux only:

  1. Is there a limit on the number of characters in the absolute path name of a file?
  2. Is there a limit on the number of characters for the filename (without extension) only?

If so, what might these limits be? How can I access them in case they are system specific?

Edit
Report

1 Answer

9

The Single UNIX Specification mentions NAME_MAX and PATH_MAX constants in limits.h that can be read with pathconf. However, this is very filesystem dependent, and you are unlikely to hit such a limit.

NOTE: As a programmer, you should not hard-code these limits. You should use dynamic allocation, so that it will always work so long as the underlying system allows for whatever you are doing.

answered 2011-07-04T12:35:11.497

Your Answer