- 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
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
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-15-2006 12:22 AM
09-15-2006 12:22 AM
Re: grep recursive
You can still assign JRF the points he deserves. Click on the "reopen thread" button, then assign the points, then click on the "close thread" button.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2006 01:15 AM
09-15-2006 01:15 AM
Re: grep recursive
Thread is not closed. Please assign points to JRF. He deserves it.
Thanks,
IT_2007
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2006 06:26 PM
09-17-2006 06:26 PM
Re: grep recursive
ok, before weekend was be problematic connect with forum. This morning it's ok! assigned points.
we can close the thread.
thanks to all
regards.
Francesco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2006 07:48 PM
09-17-2006 07:48 PM
Re: grep recursive
when i run the script from / of my hp-ux, after several minutes i receive this error:
/usr/bin/grep: The parameter list is too long.
I don´t know where have stopped.
i use:
grep -i force `find / -exec file {} \; | grep -v directory | grep -v executable | awk -F':' '
{print $1}'`
How i can remove this problem?
Thanks.
Best regards.
Francesco
- Tags:
- Arg list too long
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2006 08:08 PM
09-17-2006 08:08 PM
Re: grep recursive
for the other option with:
#!/usr/bin/sh
typeset DIR=$1
typeset PAT=$2
find ${DIR} -xdev -type f | while read FILE
do
[ `file ${FILE} | grep -ic ascii` -eq 0 ] && continue
grep "$PAT" ${FILE} /dev/null
done
exit
I have introduced -i option for uppercase. But one question: how i can do it for find only word "force" and no returning me other words how for example "forced" where force it's present?
Thanks.
Best regards.
Francesco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2006 10:23 PM
09-17-2006 10:23 PM
Re: grep recursive
A simple 'grep' will match the string of characters without regard to where they occur. A simple solution for finding only the word "force" would be:
# grep -i -e "^force " -e " force$" -e " force "
The caret (^) anchors the string to the beginning of a line. The dollar sign ($) anchors the string at the line's end. Surrounding the string with spaaces " " creates the sense of an English word.
In answer to your question regarding Peter's script, the "parameter list is too long" error arises because the 'find' is creating a list of files for input the 'grep'. The list generated is too long to be passed to 'grep' in one unit.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 04:28 PM - edited 10-29-2011 07:10 PM
09-18-2006 04:28 PM - edited 10-29-2011 07:10 PM
Re: grep recursive
>grep -i force `find / -exec file {} \; | grep -v directory | grep -v executable | awk -F':' '
{print $1}'`
Peter's script is not the proper way to use find, if it will return an infinite number of files. You must use xargs or better yet use -exec grep +.
It seems you can only use -exec file +. But you shouldn't use `find ...`.
You need to replace by:
find / -exec file + | \
grep -v -e directory -e executable | \
awk -F":" '{print $1}' | xargs -n40 grep -i force
You may want to add 2> /dev/null to the find and the last grep.
>how i can do it for find only word "force" and no returning me other words how for example "forced" where force it's present?
You need to use grep -w. (If you are on 11.11) This is easier than James' solution. Otherwise a more rigorous solution for 11.00 would use
[[:space:][:punct:]] where he has a blank, before and after your word "force".
- Tags:
- regex
- « Previous
-
- 1
- 2
- Next »