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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-08-2005, 04:44 PM
|
#1
|
LQ Newbie
Registered: Jun 2005
Posts: 9
Rep:
|
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
|
|
|
07-08-2005, 04:53 PM
|
#2
|
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821
Rep: 
|
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.
|
|
|
07-08-2005, 05:12 PM
|
#3
|
LQ Newbie
Registered: Jun 2005
Posts: 9
Original Poster
Rep:
|
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
|
|
|
07-09-2005, 06:26 PM
|
#4
|
Member
Registered: May 2005
Posts: 378
Rep:
|
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 07:27 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|