The shell extracts the file suffix name and determines whether it is a specific string

Source: Internet
Author: User

If the file is a. css file or a. js file, it is processed.

File=$1

if ["${file##*.}" x = "css" x]| | ["${file##*.}" x = "JS" x];then

Do something

Fi

Attention:

1> extract file suffix name: ${file##*.}

# #是贪婪操作符, matching from left to right, matching to the rightmost., removing the left content that contains the. Number.

Here you can refer to http://www.1987.name/264.html

2> is =, and there are spaces on both sides, if there is no space, will error

3> added x to prevent string errors from being empty times.

Here you can refer to http://qubaoquan.blog.51cto.com/1246748/292461



Find the file name in the current directory that contains. py,.sh,.css,.js,.html,

For n in ' find. -name "*.py"-o-name "*.sh"-o-name "*.css"-o-name "*.js"-o-name "*.html" "; Todo

Something

Done

Attention:

1> find the name of the file at the end of the current directory as. py, or. sh, or. css, or. js, or. html, and handle



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.