LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Clarification needed in this reg exp/awk code (https://www.linuxquestions.org/questions/programming-9/clarification-needed-in-this-reg-exp-awk-code-341372/)

mselvam 07-08-2005 03:44 PM

Clarification needed in this reg exp/awk code
 
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

config.log
config.status
configure
configure.in
configureout
erts
install
lib
make
makeinstallerr
makeinstallout
makeinstallwarn

if i echo v or bt_cv_erts_vsn, both of them are empty.
what will be the original value of v, in my program v is not initialised to anything

meena

crabboy 07-08-2005 03:53 PM

I'm not sure I understand what you're after.

Post an example of some files that are in $ERLDIR and $ERLDIR/lib and what you expect to extract from it.

mselvam 07-08-2005 04:12 PM

searching for erts in the ls output
 
The erts is searched on the ls output right? in my case, ls output contains erts and which is a directory

does the awk actions, will be to extract from within files? i dont think so/but i am not sure..

this code is written by someone else, but when i am making a build, i get this error.

erts is erlang library, which has been installed already by build procedures, but i do not know where version is available?


By the way when I give ls -l the second column happens to be an integer, is this the version of the file? what does this second column of ls -l means?

BUT IN MY program, it is not searching from ls -l output; instead it is meant to search on ls output which will not have a second field against erts?

meena

eddiebaby1023 07-09-2005 05:26 PM

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.


All times are GMT -5. The time now is 11:59 PM.