In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
1. Cut command
The cut command mainly accepts three positioning methods:
First, byte (bytes), with the option-b
Second, the character (characters), with the option-c
Third, fields (domain), with the option-f
Str= "abchyew2635" echo $str | cut-c 6-9
Results:
Yew2
2. # intercept, delete the left character and keep the right character
Var= "hello world" echo ${var#*l} result: lo world
Where var is the variable name, the # sign is the operator, and * l means to delete the first l and all characters on the left from the left.
That is, delete hel
3. Intercept with # #, delete the left character and retain the right character.
Var= "hello world" echo ${var##*l} result: d
# # * l means to delete the last (rightmost) l and all left characters from the left
That is, delete hello worl
4.% intercept, delete the right character and keep the left character
Var= "hello world" echo ${var%l*} result: hello wor
% l* means to start on the right and delete the first l and the characters on the right
That is, delete d
5.%% intercept, delete the right character and keep the left character
Var= "hello world" echo ${var%%l*} result: he
% l* means to start from the right, delete the last (leftmost) l and the right character
That is, delete llo world
6. Start with the number of characters on the left and the number of characters
Var= "hello world" echo ${var:0:3} result: hel
Where 0 indicates the beginning of the first character on the left, and 3 represents the total number of characters.
7. Start with the first character on the left and end it.
Var= "hello world" echo ${var:2} result: llo world
The 2 of them indicates that the third character on the left begins and ends.
8. Start with the number of characters on the right and the number of characters
Var= "hello world" echo ${var:0-2:3} result: ld
Where 0-2 indicates the start of the second character on the right, and 3 indicates the number of characters.
9. Start with the character on the right and go to the end.
Var= "hello world" echo ${var:0-2} result: ld
Indicates that it starts with the second character on the right and ends.
General Code:
#! / bin/bashvar= "hello world" echo ${var#*l} echo ${var##*l} echo ${var%l*} echo ${var%%l*} echo ${var:0:3} echo ${var:2} echo ${var:0-2:3} echo ${var:0-2} [fbl@www test6_16] $. / string.sh lo worlddhello worhehelllo worldldld
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.