cat > version-check.sh << "EOF" #!/bin/bash # Simple script to list version numbers of critical development tools export LC_ALL=C bash --version | head -n1 | cut -d" " -f2-4 MYSH=$(readlink -f /bin/sh) echo"/bin/sh -> $MYSH" echo$MYSH | grep -q bash || echo"ERROR: /bin/sh does not point to bash" unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3- bison --version | head -n1
if [ -h /usr/bin/yacc ]; then echo"/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; elif [ -x /usr/bin/yacc ]; then echo yacc is `/usr/bin/yacc --version | head -n1` else echo"yacc not found" fi
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 diff --version | head -n1 find --version | head -n1 gawk --version | head -n1
if [ -h /usr/bin/awk ]; then echo"/usr/bin/awk -> `readlink -f /usr/bin/awk`"; elif [ -x /usr/bin/awk ]; then echo awk is `/usr/bin/awk --version | head -n1` else echo"awk not found" fi
gcc --version | head -n1 g++ --version | head -n1 grep --version | head -n1 gzip --version | head -n1 cat /proc/version m4 --version | head -n1 make --version | head -n1 patch --version | head -n1 echo Perl `perl -V:version` python3 --version sed --version | head -n1 tar --version | head -n1 makeinfo --version | head -n1 # texinfo version xz --version | head -n1
laohoo@laohoo-Virtual-Machine:~/Downloads$ bash version-check.sh bash, version 5.1.16(1)-release /bin/sh -> /usr/bin/dash ERROR: /bin/sh does not point to bash Binutils: (GNU Binutils for Ubuntu) 2.38 bison (GNU Bison) 3.8.2 /usr/bin/yacc -> /usr/bin/bison.yacc Coreutils: 8.32 diff (GNU diffutils) 3.8 find (GNU findutils) 4.8.0 GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1) /usr/bin/awk -> /usr/bin/gawk gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0 version-check.sh: line 35: g++: command not found grep (GNU grep) 3.7 gzip 1.10 Linux version 5.15.0-41-generic (buildd@lcy02-amd64-065) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 m4 (GNU M4) 1.4.18 GNU Make 4.3 GNU patch 2.7.6 Perl version='5.34.0'; Python 3.10.4 sed (GNU sed) 4.8 tar (GNU tar) 1.34 version-check.sh: line 46: makeinfo: command not found xz (XZ Utils) 5.2.5 version-check.sh: line 49: g++: command not found g++ compilation failed
存在的问题
shell 脚本未指向 bash 而是指向 dash:
1 2
/bin/sh -> /usr/bin/dash ERROR: /bin/sh does not point to bash
执行以下命令进行修复:
1
sudoln -sf bash /bin/sh
g++ 没有安装
1 2
version-check.sh: line 49: g++: command not found g++ compilation failed
执行以下命令安装 g++:
1
sudo apt install g++
makeinfo 没有安装
1
version-check.sh: line 46: makeinfo: command not found