小编Cur*_*bie的帖子

Bash:如何跳过卡住的功能?

#!/bin/bash

function thous {
    numfmt --g $1 | sed 's/,/./g;s/@//g'
}

aa="1,235"
bb="5,22"
cc=$(echo "$aa + $bb" | bc)

#1
echo $aa
#2
echo $bb
#3
echo $(thous "$cc")
#4
echo "SKIP"

exit
Run Code Online (Sandbox Code Playgroud)

显示了什么

(standard_in) 1: parse error
(standard_in) 1: parse error
1,235
5,22
Run Code Online (Sandbox Code Playgroud)

我想要的是

(standard_in) 1: parse error
(standard_in) 1: parse error
1,235
5,22
(some error or nothing at all)
SKIP
Run Code Online (Sandbox Code Playgroud)

如果您尝试编译此 bash shell 代码,您将陷入#3。那么,如何告诉终端忽略无法处理的内容并继续下一个过程呢?

如果问题不清楚,请告诉我,谢谢

bash shell-script

4
推荐指数
1
解决办法
945
查看次数

标签 统计

bash ×1

shell-script ×1