1

Hi I am trying to us the find command and -exec to -execute a file file when found but it doesn't seem to work. here is some code:

 ssh $i find $DIRECTORY -name "version.sh" -exec sh {} \;

I am getting the error no arguments for -exec

thanks!

1
  • If the file contains a valid shebang line, you don't need the sh. Commented Aug 29, 2012 at 20:16

2 Answers 2

5

Your side gets a semicolon, but the other side doesn't.

... \\\;
Sign up to request clarification or add additional context in comments.

3 Comments

+1 To be more elaborate; your shell expands metacharacters before the command is executed. If you want the ssh command line to contain shell metacharacters, you need to quote or escape them.
The ssh command does see the semicolon, but the shell on the other side consumes it as a command separator.
Yeah, it's the backslash which needs treatment, like you show.
0

A more readable version could be:

ssh $i "find $DIRECTORY -name version.sh | xargs -r sh"

Comments

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.