- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Search specific string in a file in a sub-folder
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 12:21 AM
тАО01-13-2004 12:21 AM
What is the command to be used to search for occurance of specific string in a file present at a sub-directory from the root.
Regards,
Nameesh.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 12:25 AM
тАО01-13-2004 12:25 AM
Re: Search specific string in a file in a sub-folder
try
find . -name file|xargs grep -il "string"
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 12:27 AM
тАО01-13-2004 12:27 AM
Re: Search specific string in a file in a sub-folder
grep -l "string" /sub-directory/*
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 12:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 06:26 PM
тАО01-13-2004 06:26 PM
Re: Search specific string in a file in a sub-folder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 07:38 PM
тАО01-13-2004 07:38 PM
Re: Search specific string in a file in a sub-folder
Search all files in the current directory for the string xyz:
grep xyz *
Search all files in the current directory subtree for the string xyz,
and ensure that no error occurs due to file name expansion exceeding
system argument list limits:
find . -type f -print |xargs grep xyz
The previous example does not print the name of files where string xyz
appears. To force grep to print file names, add a second argument to
the grep command portion of the command line:
find . -type f -print |xargs grep xyz /dev/null
In this form, the first file name is that produced by find, and the
second file name is the null file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 07:51 PM
тАО01-13-2004 07:51 PM
Re: Search specific string in a file in a sub-folder
Also, what I miss is the single command solution:
find . -type f -exec grep -il {} \;
It might be less effecient as the xargs...
If you only want ASCII files, you can then filter the output using the file command on every file reported by the find command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2004 03:27 AM
тАО01-14-2004 03:27 AM
Re: Search specific string in a file in a sub-folder
Is the quetion related occurence of string in files or in a filename?
in first case:
Do you want to get number of occurence or a filelist?