How to parse the variable in .mk file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to parse the variable in .mk file?
# 8  
Old 09-05-2017
Quote:
Originally Posted by ricky-row
Hi,
I am really sorry for the confusions, I tried like this way

Code:
hacker@hacker:~$ cat test.sh 
#!/bin/bash

NEED="TEST=Name WORK=Ps DEL=let"
buf=""

while [ -n "$NEED" ] ; do
     buf="${NEED##* }"               # these two lines chop off 
     NEED="${NEED% ${buf}}"         # one item=value pair after the other

     echo "$buf"
     eval export "$buf"
done

where I got my output as
TEST=Name
TEST=Name
TEST=Name
TEST=Name
``
``.
``
The output is not ending,
How about:

Code:
NEED="TEST=Name WORK=Ps DEL=let"


for X in $NEED
do
       echo $X
done

# 9  
Old 09-06-2017
Thanks Corona,
I suppose to export those parsed individual variables and use them in the MAKEFILE. Like
Code:
echo $WORK 
Ps

echo $TEST
Name 

echo $DEL
let

Any inputs please,
I tried adding
Code:
  eval export "$X"

but I can't see in printenv

---------- Post updated at 08:07 PM ---------- Previous update was at 11:16 AM ----------

Any suggestions please,
I tried the way of using sed

Code:
	sed 's/ /\n/g' <<< $NEED

which gives output as
TEST=Name
WORK=Ps
DEL=let

but, I can't export the values, any idea to export the values in Makefile
# 10  
Old 09-06-2017
Isn't that from your makefile? Why not just set the variables you want to set?
# 11  
Old 09-06-2017
"Any inputs please" and / or "Any suggestions please" are not too popular demands in these fora, esp. if repeated several times. If people know or find an answer to - esp. somewhat unclear like your - requests, they will come up with it now or sometime - I don't think urging them like above will make them post sth. head over heels.
If I only knew what the meaning of "export the values in Makefile" were, I might come up with a proposal. To me, a makefile is just textual data, a prescription of conditions and dependencies to be read and executed by the make tool. IF a variable is referenced in a makefile , and IF that variable has been exported in the parent shell, THEN make will be able to process the expanded value of the variable.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grepping for one variable while using awk to parse an associated variable

Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other. Any guidance is appreciated. File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies

2. Shell Programming and Scripting

Help about parse the variable

I'm using bash the code is QEMU_CMD="qemu-system-x86_64 -smp 2 -m 512 $QEMU_PARAMETER -hda $GUEST_IMAGE -kernel $GUEST_KERNEL -append \"root=/dev/hda rw console=ttyS0,115200 ip=$IP_PARAMETER \" -nographic" echo "..............................." echo "qemu command is... (9 Replies)
Discussion started by: yanglei_fage
9 Replies

3. Shell Programming and Scripting

How to parse xml file in variable-string?

In the wake of the post: how-parse-following-xml-file Thank you for the very useful chakrapani response 302355585-post4 ! A close question. How to pass a file to xmllint in variable? For example, let it be: NEARLY_FILE='<?xml version="1.0" encoding="iso-8859-1"?><html><set label="09/07/29"... (0 Replies)
Discussion started by: OleM2k
0 Replies

4. Shell Programming and Scripting

Parse config file data to script variable

I have a script with few pre defined variables. Also have a config file. Something like this. # config file # Define Oracle User MOD1_TAG=abcde MOD2_TAG=xyzabc MOD3_TAG=def I need to parse the config file and have each of the value copied to different variables. Please suggest what... (1 Reply)
Discussion started by: souryadipta
1 Replies

5. Shell Programming and Scripting

Parse file and copy value to variable in sh script.

Hi, I need to parse a simple text file like below and store the word that starts with BR* to a variable say $BRno. I need to do this in sh script. NOTE: the length of the numbers following BR is not constant (eg: it could be BR1234 or BR22233). And there is only 1 BRxxxxx in a file at a given... (6 Replies)
Discussion started by: script2010
6 Replies

6. Shell Programming and Scripting

Parse text file in shell & store to variable

Hi, I need to parse a simple text file like below and store the word that starts with BR* to a variable say $BRno. I need to do this in sh script. NOTE: the length of the numbers following BR is in constant. And there is only 1 BRXXX in a file at a given time. .txt file: BR276828... (1 Reply)
Discussion started by: script2010
1 Replies

7. Shell Programming and Scripting

how to parse value of the variable

I have a variable which has a full path to the file, for example : A=/t1/bin/f410pdb Does anybody know the command to parce this variable and assign the result to 3 other variables so each subdirectory name will be in a new variable like this B=t1 C=bin D=f410pdb Many thanks -A (5 Replies)
Discussion started by: aoussenko
5 Replies

8. Shell Programming and Scripting

Parse String from a Variable

Hello, Is there a quick way to parse the values from a variable? The variable has the following sample input: TA= The values of the TA variable is not fixed/hardcoded Basically I need to get the IV_Test and PF_SAPP_FWK values. I created a script that first use sed to remove ,... (3 Replies)
Discussion started by: racbern
3 Replies

9. Shell Programming and Scripting

parse variable

I have a variable (it is a date actually -> 2007-01-03) which would be passed in as parameter, what I want is to parse in and put year, month, and day in separate variables, I have tried the following but doesn't work echo $dt | awk -F- '{print $1 $2 $3}' | read y m d Thanks in... (2 Replies)
Discussion started by: mpang_
2 Replies

10. Shell Programming and Scripting

parse a string variable

Hello all, need a little help. I have an input variable such as ARGV which equals something like /use/home/name/script/test.dat I need to be able to get just the "test.dat" (i.e. the file name) at the end of the directory and the directory can be anything and any length. To put it another... (3 Replies)
Discussion started by: methos
3 Replies
Login or Register to Ask a Question