- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find and grep
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
12-14-2004 08:11 AM
12-14-2004 08:11 AM
I am doing
(find . -name "*" -print |xargs "mystring" -print >/tmp/out.txt)>>& /tmp/err.txt
I can run it on commnad line but when I run it thru a script i am getting an error.
Syntax error at line 2 : `&' is not expected.
The reason to run it thru a script because i want to sudo to run the script so that i can read most of the directories.
Any other find type or any other solution??
btw i am trying to run it on SunOS
Appreciate your help
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 08:23 AM
12-14-2004 08:23 AM
Solution# ( find . | xargs grep "mystring" >/tmp/out.txt) 2>> /tmp/err.txt
You used a csh like syntax
% ( find . | xargs grep "mystring" >/tmp/out.txt) >>& /tmp/err.txt
But GNU grep is the easiest for that
# grep -r "mystring" .
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 08:25 AM
12-14-2004 08:25 AM
Re: find and grep
find . -print | xargs grep -l "mystring" >/tmp/err.txt
I'm not sure why you have the "&" in the command. Usually it is used to redirect to another file number.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 08:27 AM
12-14-2004 08:27 AM
Re: find and grep
# hpeas01:/root/bin/search.ksh SDA 11/21/01
#
# Find the string
#
USAGE="search.ksh
#
# Check for 1 argument:
if (( $# != 1 ))
then
print $USAGE
exit 1
fi
STRING=$@
find . -type f | while read FILE
do
file $FILE | grep -q text
if [[ $? = 0 ]] # We have a text file
then
strings $FILE | grep $STRING
if [ $? = 0 ] # I found the
then
print "==> " $FILE "\n"
fi
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 08:28 AM
12-14-2004 08:28 AM
Re: find and grep
To find mystring in the filename use:
find . -name "*mystring*" 1>/tmp/out.txt 2> /tmp/err.txt
To find mystring in the files use:
find . -exec grep -l "mystring" 1>/tmp/out.txt 2> /tmp/err.txt
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2004 12:33 AM
12-15-2004 12:33 AM
Re: find and grep
for "mystring" within files:
find . -type f -exec grep -l "mystring" {} \; 1>/tmp/out1.txt 2> /tmp/err1.txt
for "mystring" within file names:
find . -type f -name "*mystring*" 1>/tmp/out1.txt 2> /tmp/err1.txt
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2004 03:33 AM
12-15-2004 03:33 AM