Sunday, 22 December 2019

bash - How to replace a command with the result of another in linux?


I want to create a command which uses the result of another like this:


JNLP_FILE='find . -name viewerApplet.jnlp'
cp ${JAR_FILE} ../../sign-jar/$PROFILE/

But I don't know how to execute the find command to use for the 'cp' command.


Any help?



Answer



You can use a dollar sign followed by the command in parentheses [$()] to have the output of that command fed directly into the command line:



cp $(find . -name viewerApplet.jnlp) ../../sign-jar/$PROFILE/



Alternatively, you can use backticks (`):

cp `find . -name viewerApplet.jnlp` ../../sign-jar/$PROFILE/

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...