Not to be critical of anyone, I believe that using 'head' along with 'awk' in this kind of context as a one-off quick solution to be run on the command line may very well be justified. However, in a script, 'awk' or 'sed' alone are more than capable of doing most of the things we may be looking to achieve by using a combination of 'head', and 'awk'.
The proposed implementation relies on 'sed' to perform all the text processing required. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Arch Linux openSuSE 13.2 Signed-off-by: Alexander Kapshuk <alexander.kaps...@gmail.com> --- --- linux/scripts/ver_linux.orig 2015-08-30 21:34:09.000000000 +0300 +++ linux/scripts/ver_linux 2015-09-30 22:53:42.750469252 +0300 @@ -62,8 +62,17 @@ echo -n "Linux C Library " sed -n -e '/^.*\/libc-\([^/]*\)\.so$/{s//\1/;p;q}' < /proc/self/maps -ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \ -'NR==1{print "Dynamic linker (ldd) ", $NF}' +lddsed=' + /^ldd/!d + s/.*[ \t]\([0-9\.]*$\)/\1/ + s/^/Dynamic linker (ldd)\t/ +' +if ldd -v >/dev/null 2>&1 +then + ldd -v 2>&1 | sed "$lddsed" +else + ldd --version 2>&1 | sed "$lddsed" +fi ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so 2>/dev/null | awk -F. \ '{print "Linux C++ Library " $4"."$5"."$6}' -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/