× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sourcing is a way to load variables and functions into a current environment
(among other things). By way of example: This is how to source the file
(see period space below).. and a couple of demonstrations of the effect:

/home/DLOVELADY>

cat demo_file
EWREST_id_0='861';
EWREST_wfstate_0='Open';
EWREST_summary_0='SummSumm -TW';
EWREST_boss_ciss_customer_no_0='1234';
EWREST_id_1='761';
EWREST_wfstate_1='Open';
EWREST_summary_1='Test -TW';
EWREST_boss_ciss_customer_no_1='123456789';
/home/DLOVELADY>

. ./demo_file # (Note the PERIOD SPACE PATH/FILE syntax)
/home/DLOVELADY>

# Now demo_file is loaded into my memory, so that:
/home/DLOVELADY>

echo $EWREST_id_0
861
/home/DLOVELADY>

echo $EWREST_summary_1
Test -TW
/home/DLOVELADY>


So that in a shell script, one might accept some variable for query, then
echo back the value of that variable.
--------------------------------------------

Use of grep with sed to solve:

VAR=EWREST_summary_0; grep "^${VAR}=" demo_file | sed -e "s/${VAR}='//" -e
"s/';$//"

Above sets our "search value" to EWREST_summary_0, then calls upon grep to
find lines that start with that value followed immediately by =.
It passes that result to sed, and sed is tasked with stripping out the
search vaule and the = character... and with stripping out the ending ';
characters... and echoing the result.

In and of themselves, neither solution is very practical, though. That's
why I asked, what's the larger vision of what you'd like to do?

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"We do not stop playing because we are old. We grow old because we stop
playing."
-- Anon


my unix skill is minimum at best. Can you please give me a bit more
clue on
what you mean? I'm currently think about using your readline utility
to
read the file one line at a time and then parse it.

Thanks

"Scott Klement" <midrange-l@xxxxxxxxxxxxxxxx> wrote in message
news:mailman.41003.1304028180.2702.midrange-l@xxxxxxxxxxxx...
QShell might work -- depending on the specifics.

But with the example you posted, if it were sourced into a shell
script,
it would be loaded into variables.

On 4/28/2011 4:33 PM, Hockchai Lim wrote:
I've a ifs file with content like below:
EWREST_id_0='861';
EWREST_wfstate_0='Open';
EWREST_summary_0='SummSumm -TW';
EWREST_boss_ciss_customer_no_0='1234';
EWREST_id_1='761';
EWREST_wfstate_1='Open';
EWREST_summary_1='Test -TW';
EWREST_boss_ciss_customer_no_1='123456789';

Each line basically contains a key-value pair data. Does anyone
know if
there is already an open source utility that can read and parse this
type
of
data file where caller can basically ask for a pair of data at a
time?

thanks








--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.