In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Use the method that comes with unix:
${varible##*string} intercepts the string after the last string from left to right
${varible#*string} intercepts the string after the first string from left to right
${varible%%string*} intercepts the string after the last string from right to left
${varible%string*} intercepts the string after the first string from right to left
"*" is just a wildcard. You don't have to.
$test1=123456.txt
$echo ${test1%.txt}
123456
$echo ${test1#*23}
456.txt
$test2=$ {test1%.txt} '.rst'
$echo $test2
123456.rst
2. Use the cut command
$test1=123456.txt
$echo $test1 | cut-f 1-d.
123456
I have a slight question here, why can't you assign this value to another variable? For example:
$test2=echo $test1 | cut-f 1-d.
Ksh: 123456.txt: not found.
$echo test2=$test1 | cut-f 1-d.
Test2=123456
$echo $test2
Test2 has no value here, why?
I suddenly thought of the backquotation marks in shell. The one above the TAB key, the part enclosed by the backquotation marks, will be executed first, and the following test has been done:
$test2= `echo $test1 | cut-f 1-d. `
$echo $test2
123456
$test2= `echo $test1 | cut-f 1-d. ``.rst'
$echo $test2
123456.rst
Success!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.