Help needed with find command

Hi Guys,

Can someone help with this.

I have to find out a file name which calls the following sql script "abhishek_to_sdw.sql". In other words it contains a pattern like "abhishek_to_sdw.sql".

I have found out using "find" command that the file abhishek_to_sdw.sql is existing on the server.

Please help me in this.

Regards,
Abhi

Your question is confusing. Can you please clarify ?

I have a sql script (abhishek_to_sdw.sql) which is called by some unix shell script file. I dont know which shell script calls this sql script and I want to find that shell script.

Please help me how to find a file with a pattern. which in this case is "abhishek_to_sdw.sql".

Regards,
Abhi

If your grep understands the -r flag, just use that.

fgrep -r abishek_to_sdw.sql /

Or with find,

find / -type f -exec fgrep abishek_to_sdw.sql /dev/null {} \;

Or with xargs,

find / -type f -print0 | xargs -r0 fgrep abishek_to_sdw.sql

The find -exec is the least efficient, but somewhat more portable than the others, which depend on GNU-like features. (You can avoid that in the xargs command by taking out the zeros.)

You need to find all files and grep for your pattern " ". Once you get the result print it.

find . -type f | xargs grep "abishek_to_sdw.sql"
  • nilesh