01. Command Overview basename - strip directories and suffixes from file names The basename command is used to print the base name of a directory or file. The basename and dirname commands are often used in command substitution in shell scripts to specify output file names that differ from the specified input file names. 02. Command format basename name[suffix] basename Option 03. Common options Show NAME with directory components removed. If SUFFIX is specified, the trailing SUFFIX is removed as well. --help Display help information and then end --version Display version information and then end 04. Reference examples 4.1 Display file names without directories [deng@localhost ~]$ basename /home/deng/scott_data.sql scott_data.sql [deng@localhost ~]$ 4.2 Display file name, excluding directory and suffix [deng@localhost ~]$ basename /home/deng/scott_data.sql .sql scott_data [deng@localhost ~]$ 4.3 Display file name, excluding directory and suffix -s specifies the suffix to remove [deng@localhost ~]$ basename -s .sql /home/deng/scott_data.sql scott_data [deng@localhost ~]$ 4.4 Output multiple parameters in order [deng@localhost test]$ basename -a ./20190712.log ./20190713.log 20190712.log 20190713.log [deng@localhost test]$ ls 4.5 Display the name of the last directory If the last one is a directory, then the name of the last directory will be displayed. [deng@localhost test]$ basename /home/deng/share/ share [deng@localhost test]$ This is the end of this article about how to use the Linux basename command. For more information about the Linux basename command, please search 123WORDPRESS.COM’s previous articles or the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: jQuery implements sliding tab
>>: Websocket+Vuex implements a real-time chat software
This article uses an example to describe the mana...
This article shares the specific code for the WeC...
Preview knowledge points. Animation Frames Backgr...
1. Implementation principle of Nginx load balanci...
Table of contents Props comparison of class compo...
Table of contents mousejoint mouse joint distance...
1. Create users and authorize Creating users and ...
The arrangement layout of aligning the two ends o...
Find mirror We can search for images from the Doc...
All prerequisites require root permissions 1. End...
Preface: I have always wanted to know how a SQL s...
This article mainly introduces the dynamic SQL st...
The difference between http and https is For some...
<br />This is an article I collected a long ...
zabbix Zabbix ([`zæbiks]) is an enterprise-level ...