- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How do I search for a particular string inside...
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
Forums
Discussions
Discussions
Discussions
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
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
11-01-2000 01:12 PM
11-01-2000 01:12 PM
Just a quick and probably very easy question I am trying to find out. Does anyone know how do I search for a particular string inside of a file?
This is different than from the command line where I usually use the Find command.
Thanks in advance for your help....
S Aldrich
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2000 01:17 PM
11-01-2000 01:17 PM
Re: How do I search for a particular string inside of a File?
grep "string" file(s)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2000 01:25 PM
11-01-2000 01:25 PM
Re: How do I search for a particular string inside of a File?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2000 01:45 PM
11-01-2000 01:45 PM
Re: How do I search for a particular string inside of a File?
Thanks for your help....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2000 01:57 PM
11-01-2000 01:57 PM
Re: How do I search for a particular string inside of a File?
grep $STRING `find . -print` `find /other/paths/ -name "pattern" -print`
ie. search from current directory downwards as well as /other/paths/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2000 01:59 PM
11-01-2000 01:59 PM
Re: How do I search for a particular string inside of a File?
Perhaps this may help:
for file in $(ls /
do
grep -l "string" $file
done
From the command line, this will create a listing of all files under the
Ugly, but it'll work.
-Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2000 02:01 PM
11-01-2000 02:01 PM
Re: How do I search for a particular string inside of a File?
Imagine you want to find all files in /tmp whose name start with "f", and you want to search them for the string "hello" but don't care about the case of the letters. Then, do:
# find /tmp -name f\* -print -exec grep -i hello {} \;
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 02:35 AM
11-02-2000 02:35 AM
Re: How do I search for a particular string inside of a File?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 02:43 AM
11-02-2000 02:43 AM
Re: How do I search for a particular string inside of a File?
of files, and to avoid the "argument list
too long message", use a construct like:
find / -name "*.txt" | xargs grep mypattern
Hope this helps,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2000 11:52 PM
11-02-2000 11:52 PM
Re: How do I search for a particular string inside of a File?
I've been awarded my first 9 points !!
Thanks
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2000 10:58 AM
11-03-2000 10:58 AM
Re: How do I search for a particular string inside of a File?
find . -type f -exec grep "string" {} ;
works well, except it's hard to tell exactly *which* files matched the string. (Grep won't echo the filename if it only received one file in its argument list, which is the case when used with a 'find -exec' command.) You can fix this by piping through 'xargs,' which will pass as many arguments as it can to 'grep' on a single command line (within the compiled-in restrictions on environment size). Grep then echos each matched line preceded by "
Or use GNU grep (download the depot at http://hpux.cae.wisc.edu , or a local mirror), which has a -H option to force printing of the filename:
find . -type f -exec ggrep -H "string" {} ;
(And the incredibly useful '-C' option for printing the matched line along with several lines of 'context.')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2000 12:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2000 06:50 AM
11-06-2000 06:50 AM