PDA

View Full Version : Find File Within Certain Directory



huangyingw
April 17th, 2013, 05:40 PM
Hi,
I want to write such a script file, named AdvanceSearch.sh. It will accept 2 parameters:
$1: the path to search for;
$2: the file name with part or all path;
For example, there is a file:
/company/forms/renewal/register/form.xml
My expected command line operation would be
AdvanceSearch.sh /company/ "register/form.xml"
In the above command, /company is the $1.
"register/form.xml" is the $2.
Could someone give me some guidance?

aromo
April 17th, 2013, 06:29 PM
find is your friend. No need to create a shell script

man find

schragge
April 17th, 2013, 06:55 PM
+1
In your case the suitable find command would be
find /company -path \*/register/form.xml

huangyingw
April 17th, 2013, 07:18 PM
+1
In your case the suitable find command would be
find /company -path \*/register/form.xml
Yes, that's exactly what I want.