fbpx

Comandos Linux – Comando basename

Linux basename command

Updated: 05/04/2019 by Computer Hope

basename command

On Unix-like operating systems, the basename command strips directory information and suffixes from file names.

This document covers the GNU/Linux version of basename.

basename prints file name NAME with any leading directory components removed. It can optionally also remove any trailing suffix.

Syntax

basename NAME [SUFFIX]
basename OPTION... NAME...

Options

-a–multiplesupport multiple arguments and treat each as a NAME.
-s–suffix=SUFFIXremove a trailing suffix SUFFIX, such as a file extension.
-z–zeroseparate output with NUL rather than a newline.
–helpdisplay help information and exit.
–versionoutput version information and exit.

Examples

basename /usr/bin/sort

Outputs the string “sort“.

basename include/stdio.h .h

Outputs the string “stdio“.

basename -s .h include/stdio.h

Outputs the string “stdio“.

basename -a any/str1 any/str2

Outputs the string “str1” followed by the string “str2“.

expr — Evaluate arguments as an expression.

13 de novembro de 2019

Sobre nós

A Linux Force Brasil é uma empresa que ama a arte de ensinar. Nossa missão é criar talentos para a área de tecnologia e atender com excelência nossos clientes.

CNPJ: 13.299.207/0001-50
SAC:         0800 721 7901

[email protected]

Comercial  Comercial: (11) 3796-5900

Suporte:    (11) 3796-5900
[email protected]

Copyright © Linux Force Security  - Desde 2011.