Example of Shell getting file name and extension of file
Updated: June 27, 2014 08:50:52 Submission: junjie
This article mainly introduces examples of Shell obtaining file name and extension, and a concise version of the code example. You can understand it after reading it. Friends who need it can refer to it.
basename . # => example FILE="" echo "${FILE%%.*}" # => example echo "${FILE%.*}" # => echo "${FILE#*.}" # => echo "${FILE##*.}" # => gz # This can be written in bashfilename=$(basename "$fullfile") extension="${filename##*.}" filename="${filename%.*}"
Related Articles
Method of implementing dual-machine timed backup of mysql database in shell script
Recently, there is a requirement that a database is backed up once a day, and the main machine only needs to keep records for the last fifteen days. We decided to use shell scripts to add timed tasks to achieve this requirement. Next, through this article, we will introduce to you the method of implementing dual-machine timed backup of mysql database through shell scripts. Interested friends, let’s take a look.2022-07-072 ways to write shell scripts to read one line in a file at a time
This article mainly introduces two ways to write shell scripts to read one line in a file at a time. This article also explains two ways to read shell text files. Friends who need it can refer to it.2015-04-04Introduction to the basic syntax of Csh
This article mainly introduces the basic syntax of Csh and explains variables, arrays, command replacement, command line parameters, IO redirection and pipelines. Friends who need it can refer to it.2014-11-11Shell script study guide[IV](Arnold Robbins & Nelson H
This article mainly introduces the shell script learning guide [IV] (by Arnold Robbins & Nelson. Beebe). Friends who need it can refer to it.2014-02-02Basic introduction and detailed explanation of Shell AWK programming
AWK can be regarded as an independent language, which has the basic characteristics of the language. In other words, AWK can write extremely cumbersome and complex programs. The syntax of AWK is more difficult to receive than the syntax of Shell. This article mainly introduces the introduction and basic use of Shell AWK programming. Friends who need it can refer to it.2022-06-06Check the real-time traffic command of the network card under Centos
This article introduces six methods to view network card traffic under Linux. In the Linux system, nload, iftop, iostat and other tools are used to view network card traffic. Here we will first explain the iptraf method in detail. For those who need it, please refer to it.2015-05-05Linux shell script study guide
This article mainly introduces the relevant materials of the Linux shell script study guide. Friends who need it can refer to it.2022-09-09Definition of arrays and methods of for loop traversal in linux shell
Today, the editor will share with you an article on the definition of arrays and for loop traversal methods in linux shells. They are of good reference value and hope it will be helpful to everyone. Let's take a look with the editor2018-06-06Detailed explanation of encrypting shell scripts using shc tool
This article mainly introduces the detailed explanation of using the shc tool to encrypt shell scripts. Shc can be used to encrypt shell scripts. It can convert the shell script into an executable binary file. Friends who need it can refer to it.2014-12-12Use of shell scripting language (very full and detailed)
This article mainly introduces the use of shell scripting language. The article introduces the sample code in detail, which has certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2020-04-04