.sh脚本

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

 

例子来源

https://github.com/jackfrued/Python-100-Days/blob/master/Day31-35/31-35.%E7%8E%A9%E8%BD%ACLinux%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F.md

 

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值