shell编程就是对一堆Linux命令的逻辑化处理
.sh文件可用于将terminal中的命令按照顺序执行
执行多个命令行
例如
#!/bin/bash
python demo.py --input-video path/to/your/input/video --weights path/to/model/weights --output-format video --output-root path/to/output/root
>> termi.txt
python demo.py --input-video path/to/your/input/video --weights path/to/model/weights --output-format video --output-root path/to/output/root
>> termi2.txt
#!/bin/bash
# Clone COCO API
git clone https://github.com/pdollar/coco
cd coco
mkdir images
cd images
# Download Images
wget -c https://pjreddie.com/media/files/train2014.zip
wget -c https://pjreddie.com/media/files/val2014.zip
# Unzip
unzip -q train2014.zip
unzip -q val2014.zip
shell的第一行一般都会以#!开始来指定使用的shell类型
在linux中,除了bash shell以外,还有zsh shell等
运行方式
1.
sh test.sh # test.sh可以没有x权限
2.
./test.sh # test.sh必须有x权限
3.更多例子
例子1:输入两个整数m和n,计算从m到n的整数求和的结果
#!/usr/bin/bash
printf 'm = '
read m
printf 'n = '
read n
a=$m
sum=0
while [ $a -le $n ]
do
sum=$[ sum + a ]
a=$[ a + 1 ]
done
echo '结果: '$sum
例子来源
2万+

被折叠的 条评论
为什么被折叠?



