GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: locating path names within files using grep
Operating System - HP-UX
1849206
Members
6836
Online
104041
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
04-13-2005 04:37 AM
04-13-2005 04:37 AM
HP-UX 11.0 L2000
The below grep command only produces the following output. When the errors are not being suppressed with -s it states file is inaccessible even though I'm running as root. Do I need to take the server offline and shutdown the database to run this script to completion. After the grep command encounters inaccessible files it just stops and does not continue. Any way to suppress files that are in use or search in use files? If you have a better script let me know.
find . -exec grep -l -s '/oracle8/product/8.1.7' '{}' \; >doug.txt
./etc/passwd
./etc/oratab
./etc/rc.log
./etc/rc.log.old
./etc/sam/br/graphJGAa20027
./etc/passwd.old
./etc/passwd.old1
./etc/passwd.032305
./etc/passwd.n25
The below grep command only produces the following output. When the errors are not being suppressed with -s it states file is inaccessible even though I'm running as root. Do I need to take the server offline and shutdown the database to run this script to completion. After the grep command encounters inaccessible files it just stops and does not continue. Any way to suppress files that are in use or search in use files? If you have a better script let me know.
find . -exec grep -l -s '/oracle8/product/8.1.7' '{}' \; >doug.txt
./etc/passwd
./etc/oratab
./etc/rc.log
./etc/rc.log.old
./etc/sam/br/graphJGAa20027
./etc/passwd.old
./etc/passwd.old1
./etc/passwd.032305
./etc/passwd.n25
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 04:47 AM
04-13-2005 04:47 AM
Solution
1. Use GNU grep
# grep -r -l -s '/oracle8/product/8.1.7' . >doug.txt
2. Don't use -exec and don't grep pipes or dirs
# find . -type f | xargs grep -l -s '/oracle8/product/8.1.7'
Enjoy, Have FUN! H.Merijn
# grep -r -l -s '/oracle8/product/8.1.7' . >doug.txt
2. Don't use -exec and don't grep pipes or dirs
# find . -type f | xargs grep -l -s '/oracle8/product/8.1.7'
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 04:58 AM
04-13-2005 04:58 AM
Re: locating path names within files using grep
H.Merijn,
Your number #2 option worked great. Thank you for the quick response.
Doug
Your number #2 option worked great. Thank you for the quick response.
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 04:58 AM
04-13-2005 04:58 AM
Re: locating path names within files using grep
About the only way files would be inaccessible when running as root would be if these were temporary files that have been deleted since the find started. I suspect that you are grepping extremely large files and that is your hang or grep is dying because you are using it on binary files. You really should refine your search so that it only looks for files (not directories or device nodes) and then tests to see if these files are text files (or at least contain text).
TARGET="/oracle8/product/8.1.7"
find . -type f | while read X
do
file "${X}" | grep -q -i "text"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
grep -q "${TARGET}" "${X}"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "File: ${X}"
fi
fi
done
The "file" command will restrict you to only text files (scripts are text).
TARGET="/oracle8/product/8.1.7"
find . -type f | while read X
do
file "${X}" | grep -q -i "text"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
grep -q "${TARGET}" "${X}"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "File: ${X}"
fi
fi
done
The "file" command will restrict you to only text files (scripts are text).
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP