当前位置:网站首页>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
边栏推荐
- Open programmable infrastructure (OPI) project, redefining dpu/ipu
- DHCP operation
- More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
- C langage pour le déminage (version simplifiée)
- 得物多活架构设计之路由服务设计
- Basic properties and ergodicity of binary tree
- OSI notes sorting
- Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year
- Intermediary model -- collaboration among departments
- yeb_ Back first day
猜你喜欢

图像PANR

Microsoft Certification (dynamic 365) test

Set up your own website (14)
![[普通物理] 光栅衍射](/img/f3/965ff7cd3bb76b4f71b69b9d12ece3.png)
[普通物理] 光栅衍射

在Dialog中使用透明的【X】叉叉按钮图片

Rip/ospf protocol notes sorting

Difference between map and object

When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
浅谈MySql update会锁定哪些范围的数据

I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
随机推荐
Where is 5g really powerful? What is the difference with 4G?
Talking about the range of data that MySQL update will lock
How to apply agile development ideas to other work
Popupwindow touch event transparent transmission scheme
Interpreter mode -- formulas for dating
Prototype mode -- clone monster Army
Splicing audio files with ffmpeg-4.3
Dx12 engine development course progress - where does this course go
微信小程序中使用vant组件
等保备案是等保测评吗?两者是什么关系?
Simulation lottery and probability statistics experiment of the top 16 Champions League
Learn to use a new technology quickly
Analysis of errors in JSON conversion using objectmapper
Difference between map and object
Bridging mode -- law firm
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
Otaku can't save yuan universe
Sleep revolution - find the right length of rest
Why do we always "give up halfway"?
Pyaudio audio recording