1

how to write the command??

I tried find . -name test.bash | xargs bash dd, this threw an error bash: xx: No such file or directory

I also tried find . -name test.bash | xargs bash -c, can't work too.

8
  • Added code formatting tags. Commented Nov 27, 2017 at 15:12
  • If the script is in the current directorybash script-name arg1 arg2 ...... argn. If it is in another directory then that directory should be in $PATH, it should be executable, and it should have a #! line. Commented Nov 27, 2017 at 15:12
  • Voting to close : "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a *clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example]stackoverflow.com/help/mcve)" . Good luck. Commented Nov 27, 2017 at 15:12
  • What happens when you run find . -name test.bash does it find anything? Commented Nov 27, 2017 at 15:13
  • 1
    Please also review the output from xargs with the -t (AKA --verbose) option. This will make xargs print out the command and argument it runs. man7.org/linux/man-pages/man1/xargs.1.html Commented Nov 27, 2017 at 18:41

1 Answer 1

4

I created a test script, super simple, it just prints the arguments.

#!/bin/bash
echo "$@"

Then I find it in it's directory and call it with arguments:

find . -name test.bash -exec {} arg1 arg2 \;

It runs and outputs "arg1 arg2".

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

1 Comment

@fujian26: good morning, please accept the answer (check mark on the left of the question).

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.