View Full Version : [SOLVED] Using find in a bash script ?

January 21st, 2011, 03:48 PM
I mostly/always use find with -iname and directory as . So I want to make a bash script to do this so how will I get the search string into the bash script?

So here the value of x will change every time I run the script so how will I get the value of x into the script?

find . -iname "*x*"
Sorry if the question is hard to understand :(

Dr Small
January 21st, 2011, 03:50 PM
find . -iname "$1"

January 21st, 2011, 04:10 PM
Putting a / at the end of #! /bin/bash can cause errors.

January 22nd, 2011, 04:54 AM
find . -iname "$1"

Can you please explain? The script ?

January 22nd, 2011, 12:23 PM
theres not really much to explain, $1, $2, $3 etc. contain the values passed as arguments on the command line when you run a command.

so if you run a script like so:

./yourscript /home/you/somedirectory someotherparameter

then in your script $1 would contain the value /home/you/somedirectory, and $2 would contain someotherparameter

January 22nd, 2011, 04:55 PM
And $0 would be the name of the script!!

January 23rd, 2011, 10:26 AM
Thanks !!

Dr Small
January 24th, 2011, 02:25 AM
Putting a / at the end of #! /bin/bash can cause errors.
Yeah, I didn't mean to do that... :S