Computing.Net > Forums > Unix > Problem with find script

Problem with find script

Reply to Message Icon

Original Message
Name: Selvi
Date: July 24, 2003 at 08:41:45 Pacific
Subject: Problem with find script
OS: SunOS 5.8
CPU/Ram: Don't Know
Comment:

Hi,
I have script which searches a specified directory for a particular file. I pass in 2 parameters into the script, the path and the filename. The problem is that I can only pass in the exact file name, if I want to look for a file that begins with f*, it only finds 1 record and if I passed it 'f*', it gives me the following error message:
find: bad option file2
find: path-list predicate-list
file2 is the name of my script. This is what is in the script:
find $1 -name $2 -exec ls -l \{\} \;

If I do a find2.ksh ~ 'f*', I get the error message as shown above. Anyone knows how I can stop this.
Thanks.


Report Offensive Message For Removal


Response Number 1
Name: David Perry
Date: July 24, 2003 at 12:29:45 Pacific
Subject: Problem with find script
Reply: (edit)

find $1 -name "*$2*" -exec ls -l {} \;


Report Offensive Follow Up For Removal

Response Number 2
Name: Dlonra
Date: July 24, 2003 at 14:55:16 Pacific
Subject: Problem with find script
Reply: (edit)

to avoid multiples:
find $1 -name "$2" -exec ls -l {} \;

also
set -x in the script for debugging


Report Offensive Follow Up For Removal

Response Number 3
Name: Selvi
Date: July 30, 2003 at 11:44:35 Pacific
Subject: Problem with find script
Reply: (edit)

thank you for the replies.
i would like to be able to search for multiple records.
could you please explain how to use the -x for debugging in the script.
thanks once again


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Problem with find script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge