我正在键入一个shell脚本来查找某些RHEL linux框中的总物理内存.
首先,我想强调一下,我对内核识别的总物理内存感兴趣,而不仅仅是可用内存.因此,请避免建议读取/ proc/meminfo或使用free,top或sar命令的答案- 在所有这些情况下,它们的" 总内存 "值表示" 可用内存 " 值.
首先想到的是读取引导内核消息:
Memory: 61861540k/63438844k available (2577k kernel code, 1042516k reserved, 1305k data, 212k init)
Run Code Online (Sandbox Code Playgroud)
但是在某些Linux机箱中,由于在内核启动时使用了EMC2的PowerPath软件及其泛洪启动消息,因此该有用的启动内核消息不可用,甚至在/ var/log/dmesg文件中也是如此.
第二个选项是dmidecode命令(由于某些旧内核和架构的限制,我警告内核识别的RAM和实际RAM可能不匹配).选项--memory简化了脚本,但我意识到该命令的旧版本没有--memory选项.
我的最后一次机会是getconf命令.它报告内存页面大小,但不报告物理页面的总数 - _PHYS_PAGES系统变量似乎是可用的物理页面,而不是总物理页面.
# getconf -a | grep PAGES PAGESIZE 4096 _AVPHYS_PAGES 1049978 _PHYS_PAGES 15466409
我的问题:是否有其他方法可以获得物理内存的总量,适合由shell脚本解析?
我正在尝试在已安装旧 OpenSSL 版本的 Linux 机器中构建OpenSSH 7.3p1 。
\n\n首先,我已成功编译OpenSSL 1.0.2h并安装在 中/opt/openssh-1.0.2h,而不是/usr旧 OpenSSL 版本所在的位置。
tar xzf openssl-1.0.2h.tar.gz\ncd openssl-1.0.2h\n./config --prefix=/opt/openssl-1.0.2h shared\nmake depend\nmake\nmake test\nmake install\nRun Code Online (Sandbox Code Playgroud)\n\n然后我继续使用 OpenSSH:
\n\ntar xzf openssh-7.3p1.tar.gz\ncd openssh-7.3p1\n./configure --prefix=/opt/openssh-7.3p1 --with-openssl=/opt/openssl-1.0.2h\nRun Code Online (Sandbox Code Playgroud)\n\n但configure脚本失败并显示以下错误消息:
checking OpenSSL header version... 0090802f (OpenSSL 0.9.8e-rhel5 01 Jul 2008)\nchecking OpenSSL library version... configure: error: OpenSSL >= 0.9.8f required (have "0090802f (OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008)")\nRun Code Online (Sandbox Code Playgroud)\n\n如果我使用,会显示相同的消息--with-ssl-dir=/opt/openssl-1.0.2h/ssl
该工具findssl.sh(位于子目录中contrib)可以正确找到所有 …
我想我理解了可选的使用 ?(pattern-list)(bash当extglobshell 选项打开时)和默认情况下的使用ksh。例如在bash:
$ shopt -s extglob
$ V=35xAB
$ echo "${V#?(35|88)x}" "${V#35}"
AB xAB
Run Code Online (Sandbox Code Playgroud)
但是,当匹配的前缀模式只有 one?()或 one时*()(这引入了我所说的可选模式),35除非使用,否则不会被省略##:
$ echo "${V#?(35|88)}" "${V#*(35|88)}" # Why 35 is not left out?
35xA 35xA
$ echo "${V##?(35|88)}" "${V##*(35|88)}" # Why is it omitted when ## is used?
xA xA
Run Code Online (Sandbox Code Playgroud)
?()当和*()用于匹配后缀模式时(使用%和) ,会报告相同的行为%%:
$ echo …Run Code Online (Sandbox Code Playgroud) 我在最后一个命令行中发现了以下bash行为.对我来说,这完全出乎意料.
$ set | grep ^BASH_VERSINFO # Show the array
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")
$ echo "${BASH_VERSINFO[@]}" # Print all array
3 2 25 1 release x86_64-redhat-linux-gnu
$ echo "${BASH_VERSINFO[@]%e}" # Print all array removing final 'e' of every member
3 2 25 1 releas x86_64-redhat-linux-gnu
$ i=4; echo "${BASH_VERSINFO[i]}" # Print an array member
release
$ i=4; echo "${BASH_VERSINFO[i++]}" # Print an array member and increase the 'i' variable
release
$ i=4; echo "${BASH_VERSINFO[i]%e}" # Print an …Run Code Online (Sandbox Code Playgroud)