Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You can use a dollar sign followed by the command in parentheses [$(<command>)] 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/
share|improve this answer
1  
The $(command substitution) syntax is generally preferred over backticks these days. –  glenn jackman Mar 8 '12 at 1:40
    
@glennjackman, I've edited my post to reflect your comment. –  DragonLord Mar 8 '12 at 22:56
add comment
find . -name viewerApplet.jnlp -exec cp {} ../../sign-jar/$PROFILE/ \;

-exec lets you feed the results of find to another command. {} stands in for the name of the file found. Note that if find has more than one result it will copy them all into the specified directory (presumably you have only 1 file called viewerApplet.jnlp, but exec also works for things like find . -name *.java -exec cp {} backups/ \;)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.