我想通過提取ldd --version
輸出驗證glibc版本。下面是從Ubuntu的機器的例子:用bash腳本提取ldd --version
ldd (Ubuntu GLIBC 2.21-0ubuntu4) 2.21
這裏是另一個從一個CentOS 6.5的機器:
ldd (GNU libc) 2.17
謝謝
克里斯
我想通過提取ldd --version
輸出驗證glibc版本。下面是從Ubuntu的機器的例子:用bash腳本提取ldd --version
ldd (Ubuntu GLIBC 2.21-0ubuntu4) 2.21
這裏是另一個從一個CentOS 6.5的機器:
ldd (GNU libc) 2.17
謝謝
克里斯
用awk:
$ ldd --version | awk '/ldd/{print $NF}'
2.19
Bas如果該行包含字符串ldd
,則打印最後一個字段。
在您的系統上查看glibc版本的最佳方式是執行libc.so文件,就像看起來很奇怪: –
發現您正在使用的libc版本的正確方法是執行libc.so
文件。是的,這很奇怪,但這是你應該怎麼做的,ld --version
作爲ldconfig --version
是不正確的。
$ /lib/powerpc64le-linux-gnu/libc.so.6
GNU C Library (Ubuntu GLIBC 2.21-0ubuntu4) stable release version 2.21, by Roland McGrath et al.
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.9.2.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.
你想把'2.21'和'2.17'作爲輸出嗎? – anubhava