ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
In my bash script, the $ERLDIR contains following:
/lhome/mselvam/vpn-5-5/otp/
and I have the code as:
bt_cv_erts_vsn="`ls ${ERLDIR} ${ERLDIR}/lib | \
awk -F- '/^erts-/ { if ($2 > v) v=$2; }
END { print v; }'`"
case "$bt_cv_erts_vsn" in
"")
{ echo "configure: error: "Could not figure out version Erlang library: erts"" 1>&2; exit 1; }
;;
*)
;;
esac
and I am getting the eror as:
checking erts version... configure: error: Could not figure out version Erlang library: erts
My understanding is, the above code, searches for the pattern erts- at the beginning of each line of the output of the ls command of 2 directories, and
prints the version v onto the bt_cv_erts_vsn
before doing so it is replacing the v with the second field of the matching line if the second field of the matching line was > v.
Is my understanding right? or am i wrong?
also my doubt is what is the second field it will look?
it can match erts (and not erts-) in one of the lines below (ls output), but there is no second field in it
The second column of ls -l is the link count, which shows how many directory entries are referring to the file/directory. ls on its own, when not outputting to stdout, will show each filename on a single line; your awk command is splitting that line on a hyphen character, so the second field will be (presumably) the version number of the library named erts-n.n.n.so or whatever.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.