Application Technology of shell variable quantum string

Source: Internet
Author: User

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8C/17/wKioL1hiDtOToZ39AAPTKCCfJ7g699.png "title=" 1.png " alt= "Wkiol1hidtotoz39aaptkccfj7g699.png"/>

[Email protected] zhouyu]# a= "I am Zhouyu"

[Email protected] zhouyu]# echo ${#a}

11

[Email protected] zhouyu]# echo $a | Wc-m

12

[[email protected] zhouyu]# echo ${a:2}

Am Zhouyu

[[email protected] zhouyu]# echo ${a:2:3}

Am

[Email protected] zhouyu]# echo $a | Cut-b 3-4

Am

[[email protected] zhouyu]# echo ${a#i am}

Zhouyu

[[email protected] zhouyu]# echo ${a# #i am}

Zhouyu

[[email protected] zhouyu]# echo ${a%zhouyu}

I am

[[email protected] zhouyu]# echo ${a%%zhouyu}

I am

[Email protected] zhouyu]# echo ${a/i am/you is}

You are Zhouyu

[email protected] zhouyu]#

Below we write a script let 1_zhouyu.txt 2_zhouyu.txt 3_zhouyu.txt the name of three files renamed to 1.txt 2.txt 3.txt file, how to change it. can refer to the following documents I wrote

What better way to ask Daniel to give a little advice

vim/root/zhouyu/1.sh content is

Cd/root/zhouyu

For i in ' LS *.zhouyu.txt ';

Do

MV $i ${i/_zhouyu.txt/.txt}

Done

That's how it works.

Here is the command rename, which is specifically used to change the file name, as follows:

Rename want to change the part changed to what changes the source file, below is an example

[[email protected] zhouyu]# ls

1.txt 2.txt 3.txt zhouyu.sh

[Email protected] zhouyu]# rename. txt. txt/root/zhouyu/*

[[email protected] zhouyu]# ls

1.TXT 2.TXT 3.TXT zhouyu.sh

[Email protected] zhouyu]#


This article is from "Love Zhou Yu" blog, please be sure to keep this source http://izhouyu.blog.51cto.com/10318932/1886563

Application Technology of shell variable quantum string

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.