[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Recommended way to truncate a shell variable value in autoconf
From: |
Dale Visser |
Subject: |
RE: Recommended way to truncate a shell variable value in autoconf |
Date: |
Fri, 21 Feb 2014 19:22:03 -0500 |
Eric:
My experience with expr just prior was that it was matching too greedily on the
character class. I had just assumed I would need two steps with sed, too.
However, I checked and your suggestion works as I need it to.
I think the difference is that in expr, one specifies what part of the
expression match to keep. The sed command is specifying what to replace, so in
that case greedy matching worked in my favor.
Thank you!
Dale
--
Date: Fri, 21 Feb 2014 17:09:28 -0700
From: address@hidden
To: address@hidden; address@hidden
Subject: Re: Recommended way to truncate a shell variable value in autoconf
> X=`echo "$X" | sed 's/ .*// ' | sed 's/,.*//'`
sed|sed is a waste of a fork. Just go with:
X=`echo "$X" | sed 's/[, ].*//'`