Skip to main content

return filename portion of pathname

Project description

Installation

pip install pnu-basename

BASENAME(1)

NAME

basename - return filename portion of pathname

SYNOPSIS

basename string [suffix]

basename [-a] [-s suffix] [-z] string [...]

DESCRIPTION

The basename utility deletes any prefix ending with the last slash character ('/' under Unix-like Operating Systems or '\' under Windows operating Systems) present in string (after first stripping trailing slashes), and a suffix, if given. The suffix is not stripped if it is identical to the remaining characters in string. The resulting filename is written to the standard output. A non-existent suffix is ignored. If -a is specified, then every argument is treated as a string as if basename were invoked with just one argument. If -s is specified, then the suffix is taken as its argument, and all other arguments are treated as a string.

OPTIONS

Options Use
-a|--multiple Support multiple arguments and treat each as a name
-s|--suffix SUFFIX Remove trailing SUFFIX. Implies -a
-z|--zero End each output line with NUL, not newline
--debug Enable debug mode
--help|-? Print usage and a short help message and exit
--version Print version and exit
-- Options processing terminator

ENVIRONMENT

Contrary to the original FreeBSD basename command, this version takes the POSIXLY_CORRECT environment variable into account, disabling all the command's options except the options terminator (--).

EXIT STATUS

The basename utility exits 0 on success, and >0 if an error occurs.

SEE ALSO

dirname(1), csh(1), sh(1), basename(3)

STANDARDS

The basename utility is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.

This version is fully compatible with the FreeBSD version (apart from the invalid option error message). It also implements the GNU coreutils version specific options (--multiple, --suffix, -z, --zero).

It tries to follow the PEP 8 style guide for Python code.

PORTABILITY

Tested OK under Windows (though with backslashes instead os slashes, of course).

HISTORY

The basename utility first appeared in 4.4BSD.

This version was made for The PNU project / PyNIX in order to test the b2bt command.

LICENSE

This utility is available under the 3-clause BSD license.

AUTHORS

This version was written by Hubert Tournier.

The man page is derived from the FreeBSD project's one.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pnu_basename-1.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

pnu_basename-1.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pnu_basename-1.1.0.tar.gz.

File metadata

  • Download URL: pnu_basename-1.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for pnu_basename-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ecd47f2d6e251eb3ef3ac18bf0b94f246faa9616c4def70b754a71b2970d2fd4
MD5 e0573ea64e620defd5b6b0056df75c1b
BLAKE2b-256 0bfb944aa2d6fe8c9ea25963a3c80a23a1b04d15730fde11623b1565bc75656b

See more details on using hashes here.

File details

Details for the file pnu_basename-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pnu_basename-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for pnu_basename-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ef5954c61b34b6506b173b85408553f974fb8f9b1499644eefd5d441bfb7759
MD5 1e78d9cf781db3295ad383aff742284a
BLAKE2b-256 7cde2cc8d4131a439c9221ae1296bf1e1396bc4c39e1fa59121a3a6363086b61

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page