1

I have a valid xml file which contains something like:

  <ConfigSettings>
    <pairs>
        <p>
            <Name>InstallDirectory</Name>
            <Val>/Library/Application Support/Home</Val>
        </p>

... other pairs follow ...

On the command line the following works to return the correct <Val> string:

echo 'cat /ConfigureSDK/ConfigSettings/pairs/p[Name="InstallDirectory"]/Val/text()' | xmllint --shell initsdk.xml | grep -v "^/ >"

However, when I try to assign the result to a variable within a script, e.g.,

ABC='cat /ConfigureSDK/ConfigSettings/pairs/p[Name="InstallDirectory"]/Val/text()' | xmllint --shell initsdk.xml | grep -v "^/ >"

then try

echo $ABC

nothing is printed.

I'm sure I'm missing something simple, but I have tried many variations to no avail.

Thanks for any help.

1 Answer 1

2

Use export and $(...) for capturing the output of a command.

$ export A=$(echo Hello)
$ echo $A
Hello
Sign up to request clarification or add additional context in comments.

2 Comments

Ignore the -1 I don't know what I'm doing Re voting, I was trying to give an up vote. Anyway, this certainly is the correct answer.
@user3444281 I'll edit the answer slightly, then you should be able to change your vote to an up vote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.