Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-08-2005, 03:44 PM   #1
LQ Newbie
Registered: Jun 2005
Posts: 9

Rep: Reputation: 0
Clarification needed in this reg exp/awk code

In my bash script, the $ERLDIR contains following:


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; }

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


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

Old 07-08-2005, 03:53 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
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.
Old 07-08-2005, 04:12 PM   #3
LQ Newbie
Registered: Jun 2005
Posts: 9

Original Poster
Rep: Reputation: 0
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?

Old 07-09-2005, 05:26 PM   #4
Registered: May 2005
Posts: 378

Rep: Reputation: 33
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 or whatever.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need REG EXP Help to remove line breaks webshark Programming 18 07-08-2005 04:31 PM
need clarification in this reg exp/awk code mselvam Linux - General 1 07-08-2005 03:57 PM
Lost Reg Exp editor button in Kmail linuxbeliever Linux - Software 0 05-03-2005 10:56 PM
prob with reg exp rajatgarg Programming 3 05-28-2004 09:21 AM
Reg Exp ugenn Programming 4 09-19-2002 12:01 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration