当前位置:网站首页>Shell script
Shell script
2022-06-24 21:06:00 【AcTarjan】
Variable
NAME=$ID # Will parse variables ID
NAME=AcTarjan #$NAME=AcTarjan
NAME=hello world # Will make mistakes , No spaces
NAME="$ID world" # Variables are parsed
NAME="hello world" # Spaces are allowed
NAME='$ID world' # Variables will not be resolved ,$ID Original output
NAME=`pwd` # The variable is equal to the result of the command execution output
Regular expressions
Common operations
- Determine whether the directory exists
if [ ! -d $INSTALL_DIR ]; then
echo "$INSTALL_DIR doesn't exist"
exit
fi
- Judge whether the file exists
if [ -f "/data/filename" ];then
echo " File exists "
else
echo " file does not exist "
fi
- string matching
# regular expression
if [[ $FILENAME =~ ^test.*zip$ ]];then
echo "matched $FILENAME"
else
echo "mismatched $FILENAME"
fi
- Traverse the directory
for file in `ls`
do
echo $file
done
边栏推荐
- 顺序表的基本操作
- The Google File System (GFS) learning notes
- Batch capitalization of MySQL table names
- Read all text from stdin to a string
- 刚购买了一个MYSQL数据库,提示已有实例,控制台登录实例要提供数据库账号,我如何知道数据库账号。
- Material management system based on SSM (source code + document + database)
- DAPP system customization of full chain hash game (scheme design)
- Memo mode - game archiving
- Second understanding permutation and combination
- Power apps Guide
猜你喜欢

顺序栈遍历二叉树

A/b test helps the growth of game business

Apple doesn't need money, but it has no confidence in its content

Set up your own website (14)

Learn to use a new technology quickly

Vant component used in wechat applet

Wechat applet custom tabbar
浅谈MySql update会锁定哪些范围的数据

Leetcode (135) - distribute candy

Bean lifecycle flowchart
随机推荐
Dongyuhui is not enough to bring goods to "rescue" live broadcast
Vant component used in wechat applet
yeb_ Back first day
Combination mode -- stock speculation has been cut into leeks? Come and try this investment strategy!
Sequential stack traversal binary tree
图像PANR
得物多活架构设计之路由服务设计
顺序栈1.0版本
[performance tuning basics] performance tuning standards
Static routing job supplement
CVPR 2022 remembers Sun Jian! Tongji and Ali won the best student thesis award, and hekaiming was shortlisted
Common data model (updating)
大一女生废话编程爆火!懂不懂编程的看完都拴Q了
Use the transparent [x] cross button image in the dialog
顺序表的基本操作
Microsoft Certification (dynamic 365) test
The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
Implement the redis simple client customized based on socket
Leetcode(455)——分发饼干
What are the problems with traditional IO? Why is zero copy introduced?