- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Search
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
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
тАО11-10-2008 10:26 PM
тАО11-10-2008 10:26 PM
Search
Suppose I have a directory and inside it 2000 files are present. Now my question how to search any pattern or word in all files in one stroke through command line..
Reagrds
Rkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2008 10:44 PM
тАО11-10-2008 10:44 PM
Re: Search
grep regular-expression *
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2008 11:52 PM
тАО11-10-2008 11:52 PM
Re: Search
Few examples
#grep email /tmp/* -> will list the lines containing the word "email" from all files in /tmp dir
#grep -i email /tmp/* -> Case sensitive search
#grep -c email /tmp/* -> list the no of lines in each file containing the word "email"
#grep "email doc" /tmp/* -> To search multiple words
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2008 11:56 AM
тАО11-11-2008 11:56 AM
Re: Search
run the following from root
find . -name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2008 12:47 PM
тАО11-11-2008 12:47 PM
Re: Search
find /
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2008 12:53 PM
тАО11-11-2008 12:53 PM
Re: Search
the examples using find are trying to find the requested pattern in the filenames themselves. The original request was "within the files"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2008 01:14 PM
тАО11-11-2008 01:14 PM
Re: Search
As noted, a simple:
# cd /path; grep regexp *
...would work as long as the shell doesn't expand the "*" into a list of filenames that exceeds the maximum argument size.
It is also assumed that the directory contains only "text" (Ascii) files and not binary ones (e.g. executables) that will write garbage to your terminal.
If you want to examine a directory and its subordinate directories:
# find /path -type f -exec grep -i local /dev/null {} +
...is useful. This looks at only files (not directories) and examines each file for a pattern "local". The addition of the '/dev/null' forces the output to include the filename along with the matching line regardless of how many different files are found with matches. The "+" terminator (instead of "\;") makes the operation quite performance conservative.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2008 03:04 PM
тАО11-11-2008 03:04 PM
Re: Search
# find /path -type f -maxdepth 1 -exec grep -i local /dev/null {} +
The maxdepth will only stay in the directory that you have specified and not the subdirectories. I really don't know if you need the /dev/null. But else the command on a linux or debian would be:
# find /path -type f -maxdepth 1 -exec grep -i local {} +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2008 07:26 PM
тАО11-11-2008 07:26 PM
Re: Search
I used to do
$cd /directory
$grep string * #(if u r string is abc it will look for abc (small letter) only)
or
$grep -i string * #(in this case it will search abc as well as ABC also)
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2008 03:14 AM
тАО11-12-2008 03:14 AM
Re: Search
grep -i
this will search for
HTH,
Art