fujian26
fujian26

Reputation: 80

how to find bash script, then execute it and pass some arguments

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.

Upvotes: 1

Views: 642

Answers (1)

Nic3500
Nic3500

Reputation: 8591

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".

Upvotes: 4

Related Questions