If the file is a. css file or a. js file, it is processed.
file=$1if ["${file##*.}" x = "css" x]| | ["${file##*.}" x = "JS" x];then do somethingfi
Attention:
1> extract file suffix name: ${file##*.}
# #是贪婪操作符, match from left to right, match to the rightmost. Number to remove the left side of the containing. 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 the string from being empty times wrong.
Here you can refer to http://qubaoquan.blog.51cto.com/1246748/292461
When you 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"; Do Somethingdone
Attention:
1> find the file at the end of the current directory with a. py, or. sh, or. css, or. js, or. html files, and handle
Examples are as follows:
#!/bin/bashprod_war=/home/w/rod/rod.warfunction Check_war () {for-D in ${prod_war[@]} doecho $D if ["${prod_ war##*.} " x = "war" x];then echo "Check War file [${prod_war}] Success" return 1 fi done return 0}check_warif [ $?! = 1];then echo "Fail, Invalid argument port: [${prod_war}]" exit 0;fi
The shell extracts the file suffix name and determines whether it is a specific string