Operating System - HP-UX
1752701 Members
5748 Online
108789 Solutions
New Discussion юеВ

Re: I would like to find the name "XXDBD_OKS_PRICING_VALUES" in all the files under a directory

 
SOLVED
Go to solution
Diebold_Unix_Support
Occasional Advisor

I would like to find the name "XXDBD_OKS_PRICING_VALUES" in all the files under a directory

Hi,

I would like to grep for the name "XXDBD_OKS_PRICING_VALUES" under all the files in a directory. Please let me know the command to use.

There are about 332 files under a directory. My requirement is to cat each file and check if it have "XXDBD_OKS_PRICING_VALUES" mentioned in the file.

Thanks in Advance.
SP
3 REPLIES 3
Matti_Kurkela
Honored Contributor
Solution

Re: I would like to find the name "XXDBD_OKS_PRICING_VALUES" in all the files under a directory

There are many ways to accomplish this.

The basic method:

cd directory
grep "XXDBD_OKS_PRICING_VALUES" *

If the above causes an "Arg list too long" or "Command line too long" error message (which might happen if you have tens of thousands of files in the directory, or if the files have _really_ long names), you'll need to use a more advanced method, for example:

cd directory
find . -type f -exec grep "XXDBD_OKS_PRICING_VALUES" {} \+

This method can handle large numbers of files, any special characters in the filenames, etc.

By default, the find command will examine the sub-directories of the chosen directory too. If you don't want that, you might use the -path option of the find command to restrict the search to the current directory.

MK
MK
Kenan Erdey
Honored Contributor

Re: I would like to find the name "XXDBD_OKS_PRICING_VALUES" in all the files under a directory

Hi,

find . -type f -print |xargs grep XXDBD_OKS_PRICING_VALUES.

i also looked at grep with -R parameter, but doesn't exits in hp-ux.

Kenan.
Computers have lots of memory but no imagination
Diebold_Unix_Support
Occasional Advisor

Re: I would like to find the name "XXDBD_OKS_PRICING_VALUES" in all the files under a directory

Thanks for the help.

Sajith