- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: find a string
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
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
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
тАО07-06-2004 10:57 PM
тАО07-06-2004 10:57 PM
#cd /etc
#find . -type f -exec grep -i "abc" {} \;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:03 PM
тАО07-06-2004 11:03 PM
Re: find a string
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:05 PM
тАО07-06-2004 11:05 PM
Re: find a string
"cd /etc;grep abc *"
This will give you the line with the contents and the file name.
You could get cleverer though with
"grep abc * | cut -d: -f1 | sort -u"
This will give you just the filenames
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:13 PM
тАО07-06-2004 11:13 PM
Re: find a string
cd /etc
find . -type f -print -exec grep -i "
Bye
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:14 PM
тАО07-06-2004 11:14 PM
Re: find a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:16 PM
тАО07-06-2004 11:16 PM
Re: find a string
This is how it works for me:
# ll
total 32
-rw-rw-rw- 1 root sys 2 Jul 7 16:45 one
-rw-rw-rw- 1 root sys 2 Jul 7 16:45 two
# grep 1 *
one:1
# cat one
1
# cat two
2
#
So it show me the string as well as the file name.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:19 PM
тАО07-06-2004 11:19 PM
Re: find a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:19 PM
тАО07-06-2004 11:19 PM
Re: find a string
Dear peterchu,
Please don't forget to assign points.
This is from your profile
"I have assigned points to 188 of 394 responses to my questions."
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:20 PM
тАО07-06-2004 11:20 PM
Re: find a string
cd /etc
for i in $(find . -type f)
do
tipo_fich=$(file $i|grep "abc")
if [ $? -eq 0 ];then
echo "Filename = $i">>/tmp/fich.out
grep -n "abc" $i>>/tmp/fich.out
fi
done
HTH
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:21 PM
тАО07-06-2004 11:21 PM
Re: find a string
would maybe be better (only one grep process)
I suppose that your want subdirectories. If not, use
grep -il "abc" *
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:27 PM
тАО07-06-2004 11:27 PM
Re: find a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2004 11:37 PM
тАО07-06-2004 11:37 PM
Re: find a string
If you want to do in the /etc/ directory and not in it's sub directory then,
grep 'abc' /etc/*
If you want to do it in recursive manner then,
grep 'abc' `find
grep 'abc' `find
It will search in all files. Your requirement is having a problem that search operation of abc will be done including objects too. It will prompt garbage symbols etc...!!!
Another way you can do is,
find . -type f -exec <script-name> {} \;
Use the {} value as a file name, make the script to grep the content for that.
#!/usr/bin/ksh
filename=$1
echo "$filaname $(grep -q 'abc' $filename)"
Regards,
Muthukumar.