Basename

Basename

basename is a standard UNIX computer program, when basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX Specification and is a primarily used in shell scripts.

Usage

The Single UNIX Specification specification for basename is. basename string [suffix]

:string::A pathname:suffix::If specified, basename will also delete the suffix.

Example

$ basename /usr/home/jsmith/basename.wiki ki basename.wi

Performance

Since basename accepts only one operand, it's usage within the inner loop of shell scripts can be detrimental to performance. Consider

while read file; do basename "$file" done < "some-input"

The above excerpt would cause a separate process invocation for each line of input. For this reason, sed is typically used instead:

sed 's/.*///' < "some-input"

See also

* List of Unix utilities
* dirname

External links

*


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Basename — встроенная утилита unix систем, убирающая имена каталогов и суффикс из имени файла. Если суффикс задан и идентичен концу имени, то он также удаляется из имени; basename выдаёт получившееся в результате имя на стандартный вывод. Использование… …   Википедия

  • basename — встроенная утилита unix систем, убирающая имена каталогов и суффикс из имени файла. Если суффикс задан и идентичен концу имени, то он также удаляется из имени; basename выдаёт получившееся в результате имя на стандартный вывод. Содержание 1… …   Википедия

  • Basename — ist ein Unix Programm und ein Teil des POSIX Standards.[1] Es gibt den Dateinamen ohne führende Verzeichnisnamen aus. Wird ein Suffix angegeben und stimmt dieser mit der Dateiendung überein, wird auch der Suffix entfernt. Inhaltsverzeichnis 1… …   Deutsch Wikipedia

  • Basename — Saltar a navegación, búsqueda La instrucción basename muestra en la salida estándar (stdout) el nombre de fichero que se le pase como primer parámetro, eliminando el prefijo del directorio que pueda contener. Si se indica un segundo parámetro y… …   Wikipedia Español

  • basename — ist ein Unix Programm und ein Teil des POSIX Standards.[1] Es gibt den Dateinamen ohne führende Verzeichnisnamen aus. Wird ein Suffix angegeben und stimmt dieser mit der Dateiendung überein, wird auch der Suffix entfernt. Inhaltsverzeichnis 1… …   Deutsch Wikipedia

  • Basename — La instrucción basename muestra en la salida estándar (stdout) el nombre de fichero que se le pase como primer parámetro, eliminando el prefijo del directorio que pueda contener. Si se indica un segundo parámetro y este coincide con el sufijo del …   Enciclopedia Universal

  • Proto-Indo-European to Dacian sound changes — NOTE: all html boxes in this article need to be replaced by another format. The Dacian language was a Satem Indo European Language.hort vowelsPIE has the short vowels e, o. The existence of the PIE short vowel a is disputed.The origin of the Late …   Wikipedia

  • List of English words of Turkic origin — This is a list of words that have entered into the English language from the Turkic languages. Many of them came via traders and soldiers from and in the Ottoman Empire. There are some Turkic words as well, most of them entered English via the… …   Wikipedia

  • 8.3 filename — An 8.3 filename [cite web |url=http://msdn2.microsoft.com/en us/library/aa365247.aspx |title=Naming a File |publisher=Microsoft Developer Network ] (also called a short filename or SFN) is a filename convention used by old versions of DOS and… …   Wikipedia

  • Filename — Screenshot of a Windows command shell showing filenames in a directory The filename is metadata about a file; a string used to uniquely identify a file stored on the file system. Different file systems impose different restrictions on length and… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”