1

I have a Java program that outputs table names like so:

TABLE_EXAMPLE1
TABLE_EXAMPLE2
TABLE_EXAMPLE3

How can I assign the whole output as a variable in my bash shell so that I can continue to work with the table names? Ideally, I'd like to be able to create an array of table names from the output while suppressing the output from my Java program. In other words, I don't want my Java program to print out the output, but rather I'd like it stored in a bash variable.

1

2 Answers 2

1

The following reads the stdout of the java command into a exported variable.

export JAVA_OUTPUT=`java -jar application.jar`
Sign up to request clarification or add additional context in comments.

Comments

1

You could just assign the output:

$ export MY_OUTPUT=`java -jar  MyJavaApp.jar`

1 Comment

I'm afraid you can't have spaces around the =, at least in sh/bash.

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.