
illust_70054209_20180806_225351.jpg
問題:
Ubuntu shell 截取字符串時:
bad substitution
- Code:
#!/bin/bash
b=`lsof -i:1080 | grep LISTEN`
# echo $
if [ -z "$" ]; then
echo "b is empty"
else
echo ${b:1:18}
fi
-
sh執(zhí)行腳本
h2o2@ubt:~/文檔/01-shell$ sh 01-命令輸出.sh
01-命令輸出.sh: 10: 01-命令輸出.sh: Bad substitution
解決方法:
- 使用
bash執(zhí)行腳本
h2o2@ubt:~/文檔/01-shell$ bash 01-命令輸出.sh
ython 20895 h2o2