*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> basename (1)              


 basename(1)                                                     basename(1)

 NAME    [Toc]    [Back]
      basename, dirname - extract portions of path names

 SYNOPSIS    [Toc]    [Back]
      basename string [suffix]

      dirname [string]

 DESCRIPTION    [Toc]    [Back]
      basename deletes any prefix ending in / and the suffix (if present in
      string) from string, and prints the result on the standard output.  If
      string consists entirely of slash characters, string is set to a
      single slash character.  If there are any trailing slash characters in
      string, they are removed.  If the suffix operand is present but not
      identical to the characters remaining in string, but it is identical
      to a suffix of the characters remaining in string, the suffix is
      removed from string.  basename is normally used inside command
      substitution marks (`...`) within shell procedures.

      dirname delivers all but the last level of the path name in string.
      If string does not contain a directory component, dirname returns .,
      indicating the current working directory.

    Environment Variables
      LC_CTYPE determines the interpretation of string and, in the case of
      basename, suffix as single and/or multi-byte characters.

      If LC_CTYPE is not specified in the environment or is set to the empty
      string, the value of LANG is used as a default for each unspecified or
      empty variable.  If LANG is not specified or is set to the empty
      string, a default of "C" (see lang(5)) is used instead of LANG.  If
      any internationalization variable contains an invalid setting,
      basename and dirname behave as if all internationalization variables
      are set to "C".  See environ(5).

    International Code Set Support    [Toc]    [Back]
      Single- and multi-byte character code sets are supported.

 EXAMPLES    [Toc]    [Back]
      The following shell script, invoked with the argument
      /usr/src/cmd/cat.c, compiles the named file and moves the output to a
      file named cat in the current directory:

           cc $1
           mv a.out `basename $1 .c`

      The following example sets the shell variable NAME to /usr/src/cmd:

           NAME=`dirname /usr/src/cmd/cat.c`

 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003

 basename(1)                                                     basename(1)

 RETURNS    [Toc]    [Back]
      basename and dirname return one of the following values:

           0       Successful completion.

           1       Incorrect number of command-line arguments.

 SEE ALSO    [Toc]    [Back]
      expr(1), sh(1).

      basename: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

      dirname: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003
[ Back ]
 Similar pages
Name OS Title
File::Basename IRIX extract just the directory from a path
pathchk Tru64 Checks path names
pathchk HP-UX check path names
ckconfig HP-UX verify the path names of all the FTP configuration files.
ttysrch Tru64 Lists absolute path names for tty name searches
ncheck HP-UX generate a list of path names from inode numbers
ncheck_hfs HP-UX generate a list of path names from inode numbers for a HFS file system
basename IRIX deliver portions of pathnames
cut OpenBSD select portions of each line of a file
cut FreeBSD select portions of each line of a file
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service