LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-08-2005, 04:44 PM   #1
mselvam
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:

/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
 
Old 07-08-2005, 04:53 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
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, 05:12 PM   #3
mselvam
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?

meena
 
Old 07-09-2005, 06:26 PM   #4
eddiebaby1023
Member
 
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 erts-n.n.n.so or whatever.
 
  


Reply


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 05:31 PM
need clarification in this reg exp/awk code mselvam Linux - General 1 07-08-2005 04:57 PM
Lost Reg Exp editor button in Kmail linuxbeliever Linux - Software 0 05-03-2005 11:56 PM
prob with reg exp rajatgarg Programming 3 05-28-2004 10:21 AM
Reg Exp ugenn Programming 4 09-19-2002 01:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 AM.

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