Shell

基础

{}是为了指定变量名范围,如${AAA}_BBB,否则会将AAA_BBB当作一个整体来解析,这就不对了。

技巧

遍历目录下文件并解压:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
print_help() {
echo "examples:"
echo "./unzip.sh /data/file.zip"
}

if [ $# == 0 ]; then
print_help
exit 0
fi

DataDir=$1
for File in "$DataDir"/*.zip; do
OutputDir=${File%.*}
if [ -f "$File" ]; then
unzip -o "$File" -d "$OutputDir"
fi
done

Shell
https://laplac2.github.io/tools/shell/
作者
Laplace
发布于
2022年11月1日
许可协议