- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: grep recursive
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
тАО09-14-2006 08:51 PM
тАО09-14-2006 08:51 PM
how i can find the word "force" in all text file of my hp-ux system?
grep -i force * find in executables file too..
thanks
Best regards.
Francesco
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 08:57 PM
тАО09-14-2006 08:57 PM
Re: grep recursive
- Tags:
- strings
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 08:59 PM
тАО09-14-2006 08:59 PM
Re: grep recursive
strings /etc/lvmtab |grep "vg"
which will show you only names with vg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 09:05 PM
тАО09-14-2006 09:05 PM
Re: grep recursive
i wolud find recursively where i have the word 'force' in all my files in the system...
with you suggested command i can do it this?
thanks and regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 10:21 PM
тАО09-14-2006 10:21 PM
Re: grep recursive
find /start_dir -type f -exec grep -l "force" {} \;
Be warned, however, that binary files will do not grep well. Ideally you would need to find some way to exclude binaries, perhaps by being more selective about which directories you "find" in.
Pete
Pete
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 10:54 PM
тАО09-14-2006 10:54 PM
Re: grep recursive
Question solved.
regards.
Francesco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 11:00 PM
тАО09-14-2006 11:00 PM
Re: grep recursive
Using '-exec' with 'find' causes a separate process to be forked for every file found. This can be very detrimental to your system's performance.
Secondly, you should add '-xdev' so that you do not cross mountpoints as 'find' descends directories. This would be *very* important if you were interested in searching the root 'root' filesystem (including '/etc' which is not a separate mountpoint but excluding trees like '/usr' and '/opt' which are there own mountpoints.
Thus, at a minimum, do:
# find /path -xdev -type f | xargs grep -i force
Regards!
...JRF...
- Tags:
- xargs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2006 11:06 PM
тАО09-14-2006 11:06 PM
Re: grep recursive
variation on a theme:
grep force `find / -exec file {} \; | grep -v directory | grep -v executable | awk -F':' '{print $1}'`
This should exclude directories and execuatble as defined by file (man file)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2006 12:14 AM
тАО09-15-2006 12:14 AM
Solution[ It's taken an hour to be able to post this...the Forum has been out-to-lunch ]
If you want to be able to restrict your 'grep' to only text files ( and not binary ones ) and in addition identify each file matching the pattern you specify, use:
# cat ./google
#!/usr/bin/sh
typeset DIR=$1
typeset PAT=$2
find ${DIR} -xdev -type f | while read FILE
do
[ `file ${FILE} | grep -c ascii` -eq 0 ] && continue
grep "$PAT" ${FILE} /dev/null
done
exit 0
...run as:
# ./google /path pattern
for example:
# ./google /etc hostname
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2006 12:19 AM
тАО09-15-2006 12:19 AM
Re: grep recursive
thanks to reply. Due a delay of forum i cannot submit points(the therad was closed..) ..i would 10 point for you!
Best regards.
Francesco