LinuxCommandLibrary

pathchk

checks pathnames for validity and portability

TLDR

Check path for POSIX portability

$ pathchk [/path/to/file]
copy
Check for portability to older systems
$ pathchk -p [/path/to/file]
copy
Check for empty paths
$ pathchk -P [path]
copy
Check multiple paths
$ pathchk [path1] [path2] [path3]
copy

SYNOPSIS

pathchk [-p] [-P] pathname...

DESCRIPTION

pathchk checks pathnames for validity and portability. It identifies names that may cause problems on other systems.
Default checking verifies the path is valid on the current system: proper length, valid characters, and accessible parent directories.
POSIX portability mode (-p) enforces stricter limits. It checks for characters valid on all POSIX systems and limits component lengths to 14 characters (the historical minimum).
The -P option adds checks for empty path components and names starting with hyphens, which can cause problems with command arguments.
Exit code 0 means all paths passed checks. Non-zero indicates problems were found, with error messages describing issues.
The tool helps ensure scripts and archives work across different Unix systems without pathname-related failures.

PARAMETERS

-p, --portability

Check for POSIX portability.
-P
Check for empty names and leading dashes.
--help
Show help.
--version
Show version.

CAVEATS

Portability mode is conservative. Modern systems accept longer names. Some checks may be overly strict for single-system use.

HISTORY

pathchk is part of GNU coreutils and specified by POSIX. It provides a standard way to validate pathnames for cross-platform scripts and utilities.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community