- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep but skip executables
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
08-19-2002 12:00 PM
08-19-2002 12:00 PM
How can I grep a set of files in a directory but ignoring the executables, object, and archives? Also, is there a way to grep a .gz file without having to gunzip it?
Thanks,
-Cody
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2002 12:06 PM
08-19-2002 12:06 PM
Re: grep but skip executables
Go to the target directory and run:
# grep -li
which will return the list of files having the
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2002 12:06 PM
08-19-2002 12:06 PM
Re: grep but skip executables
To look at the contents of a gz file do a 'gzcat filename.gz | grep whateveryouarelookingfor'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2002 12:10 PM
08-19-2002 12:10 PM
Re: grep but skip executables
You could use the 'file' command on the file to descern whether or not the file is an ASCII text file. If yes, then 'grep' it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2002 12:23 PM
08-19-2002 12:23 PM
Re: grep but skip executables
e.g.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2002 12:32 PM
08-19-2002 12:32 PM
Solutionso the example I gave to your other thread would have to be expanded with lines for ZIPped files:
find /parent -type f -print |
while read name; do
case "$name" in
*.gz) zcat "$name" | grep 'string' && echo "$name" ;;
*.Z) pcat "$name" | grep 'string' && echo "$name" ;;
*) case "$(file $name)" in
*text*) grep 'string' $name /dev/null ;;
esac ;;
esac
done | more
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 03:43 AM
08-21-2002 03:43 AM
Re: grep but skip executables
for i in *
do
if [ "`file $i | grep exe`" = "" ]
then
echo "not an exe"
else
echo $i "is an exe"
fi
done
This will catch only binary executables.
You could use something like:
for i in `find . -type f`
blah...
to only search 'real' files and skip links.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 05:21 AM
08-21-2002 05:21 AM
Re: grep but skip executables
find /etc -type f | xargs -l grep string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 07:13 AM
08-21-2002 07:13 AM
Re: grep but skip executables
file * | grep text | cut -f1 -d: | xargs grep [-h|-l]
For the .gz file I would use:
gunzip