01. Command Overview dirname - strip non-directory suffixes from file names The dirname command removes the non-directory part of the file name and displays only the contents related to the directory. The dirname command reads the specified path name, retains the last / and the characters following it, deletes the rest, and writes the result to standard output. If there are no characters after the last /, the dirname command uses the second-to-last / and ignores all characters after it. dirname and basename are commonly used within shell command substitution to specify an output file name that is slightly different from the specified input file name. 02. Command format dirname namedirname options 03. Common options Print NAME with the part after / removed; if NAME does not contain /, print `.' (which means the current directory). --help show help and exit --version Output version information and exit 04. Reference examples 4.1 What if the last file is a directory? [deng@localhost test]$ dirname /home/deng/share/ /home/deng 4.2 If the last file is a normal file [deng@localhost test]$ dirname /home/deng/scott_data.sql /home/deng 4.3 If the name does not contain /, then output. [deng@localhost test]$ dirname dir . [deng@localhost test]$ 4.4 Relative path case [deng@localhost test]$ dirname dir/a dir 4.5 When the path is the root directory [deng@localhost test]$ dirname / / [deng@localhost test]$ dirname // / [deng@localhost test]$ This is the end of this article about the specific usage of the Linux dirname command. For more information about the Linux dirname 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:
|
<<: Causes and solutions for slow MySQL query speed and poor performance
>>: Implementation of react routing guard (routing interception)
First execute the command: [root@mini61 setuptool...
This article shares the specific code of jQuery t...
Effect: Code: <template> <div class=&quo...
This article shares the installation and configur...
MySQL official website download address: https://...
1. Environmental Preparation Tencent Cloud Server...
Vue's simple timer is for your reference. The...
Preface I have always wanted to know how a SQL st...
Here is a case that front-end developers must kno...
In Linux systems, especially server systems, it i...
Download mysql-5.7.19-winx64 from the official we...
The file server is one of the most commonly used ...
Table of contents 1. Create a watermark Js file 2...
Modify the group to which a user belongs in Linux...
Table of contents Why use websocket Socket.io Ope...