I need to echo and export each variable like TEST, WORK. DEL
If:
1) your input is guaranteed to be properly delimited by single blanks always,
2) the item=value pairs will contain no further spaces
then the following may work, provided that you use a common shell (and not Ubuntus standard shell dash). Notice that you may need to add additional tests, trims and other measures to this skeleton because real-world input might not be as well-behaved as is ideal:
Note also that the input string is tokenized backwards, so that the input a=b c=d e=f will result in:
Do you have any idea on this and changes needed to get the output as needed please.
yes, and this probably gives a hint:
Quote:
Originally Posted by ricky-row
Notice that "$input" is not "$input" any more but "nput". I suppose half of the code (which is basically all variable expansion) is interpreted away by the make-utility itself. Also notice that make will call every command in a separate shell, therefore multi-line commands/scripts like the one i gave you will not work this way, because they need to maintain context from one line to the next.
Put the code into a script file and call that instead of directly including it into a make-rule. Furthermore, this:
Quote:
Originally Posted by ricky-row
looks different than what you gave as example input and will fail with the code i wrote anyway. Have you read the caveats i included in my first answer?
Thanks Bakunin,
But When I tried your code in the script its not stopping. It keeps on printing TEST=Name infinitely. Could you give some correction on this, please
Thanks Bakunin,
But When I tried your code in the script its not stopping. It keeps on printing TEST=Name infinitely. Could you give some correction on this, please
That is - as i have said already - because the format of your input string is not in the same format as in your post #1. This:
does not make any sense syntactically and it is not of the form item1=value1 item2=value2 item3=value3 ... which would be necessary for my algorithm to work - as i have already stated in my first answer!
Give me a REAL EXAMPLE OF WHAT YOU WANT TO PROCESS and i will give you a real solution, because what you have shown me is not only different than what you first asked to process, it will also generate a syntax error if you, to quote yourself:
Quote:
I need to echo and export each variable like TEST, WORK. DEL
because
is not a syntactically correct shell statement. Otherwise, tell me what the expected outcome should be. Show me the statement my script should produce from this input.
Hi,
I am really sorry for the confusions, I tried like this way
where I got my output as
TEST=Name
TEST=Name
TEST=Name
TEST=Name
``
``.
``
The output is not ending,
My Real Need:
where I have declared the variable in my MAKEFILE
with the same format with single space delimiting but it not just only three, it can be 'n' number.
Now I need to parse each item with its value and export them for further usage in the same MAKEFILE , as you said a=b, c=d , e=f , g=h etc..
Like say, I have done parsing
TEST=Name
WORK=Ps
DEL=let
In the same MAKEFILE, I have to make use of this WORK, where
should print. I hope I cleared the context of my need.
Any help please, I am rolling my head to get this done.
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)
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)
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)
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)
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)
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)
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)
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)
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)