yum -y install epel-release
安装epel源
yum -y install ShellCheck
直接安装即可,注意大小写,小写的话会提示无此安装包
[root@localhost ~]# shellcheck --help
unrecognized option `--help'
Usage: shellcheck [OPTIONS...] FILES...
-e CODE1,CODE2.. --exclude=CODE1,CODE2.. exclude types of warnings
-f FORMAT --format=FORMAT output format
-s SHELLNAME --shell=SHELLNAME Specify dialect (bash,sh,ksh)
-V --version Print version information
这里提示问题所在位置及优化建议
[root@localhost ~]# shellcheck test.sh
In test.sh line 8:
mycat_2=$(netstat -atnp | grep "8066"|grep "java" | grep LISTEN | wc -l)
^-- SC2126: Consider using grep -c instead of grep|wc.