当前位置:网站首页>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
边栏推荐
- How Fiddler works
- Handling of garbled JMeter response data - three solutions
- Agency mode -- Jiangnan leather shoes factory
- Set up your own website (14)
- 物聯網?快來看 Arduino 上雲啦
- Sleep revolution - find the right length of rest
- Open function
- How to apply agile development ideas to other work
- 云计算发展的 4 个阶段,终于有人讲明白了
- A/b test helps the growth of game business
猜你喜欢

主数据建设的背景

Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable

Grating diffraction

Network security review office starts network security review on HowNet

Limit summary (under update)

The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time

Prototype mode -- clone monster Army

Interpreter mode -- formulas for dating

二叉树的基本性质与遍历

物聯網?快來看 Arduino 上雲啦
随机推荐
Open function
What will you do if you have been ignored by your leaders at work?
[普通物理] 光栅衍射
Material management system based on SSM (source code + document + database)
Analysis of errors in JSON conversion using objectmapper
顺序栈1.0版本
使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
Builder mode -- Master asked me to refine pills
A/b test helps the growth of game business
opds sql组件能不能将流程参数通过上下文传给下一个组件
Leetcode (455) - distribute cookies
NPM download speed is slow
物聯網?快來看 Arduino 上雲啦
刚购买了一个MYSQL数据库,提示已有实例,控制台登录实例要提供数据库账号,我如何知道数据库账号。
Rename and delete files
How to enhance influence
Common data model (updating)
Camera rental management system based on qt+mysql
传统的IO存在什么问题?为什么引入零拷贝的?
Microsoft Certification (dynamic 365) test