$_Bash
约 257 字小于 1 分钟
scriptshellbash
2024-08-13
1. 定义解释器
#!/bin/bash
#!/usr/bin/env bash
#!/usr/bin/env node2. 定义变量
env=develop
env="Hello World"3. 条件判断
if [ $a == $b ]
then
echo "a 等于 b"
elif [ $a -gt $b ]
then
echo "a 大于 b"
elif [ $a -lt $b ]
then
echo "a 小于 b"
else
echo "没有符合的条件"
fi判断条件
4. 循环
# for循环
for index in 1 2 3 4 5; do
echo "index="$index
done
# for循环
for ((i=0; i<5; i++)); do
echo "i="$i
done
# while循环
int=1
while(( $int<=5 ))
do
echo $int
let "int++"
done