- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- check files for embedded code.
Operating System - HP-UX
1752822
Members
4337
Online
108789
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
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
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
тАО10-27-2010 04:23 AM
тАО10-27-2010 04:23 AM
Im trying to find a way to check a folder that contains 100 directories and 170,000 files, approx, it changes alot.
I want to cat the file and grep for the word "include" and then list the file so I can see the permissions.
Is the best way to do a ls -1 at the root folder, cat every file and grep for 'include' ?
Then Im lost on how to display the file permissions of that file if it finds the word 'include'. stuck...
I want to cat the file and grep for the word "include" and then list the file so I can see the permissions.
Is the best way to do a ls -1 at the root folder, cat every file and grep for 'include' ?
Then Im lost on how to display the file permissions of that file if it finds the word 'include'. stuck...
UNIX IS GOOD
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 05:23 AM
тАО10-27-2010 05:23 AM
Solution
Something like this should work:
cd /somedir
find . -type f >> filelist
for FILE in $(< filelist)
do
grep -iq include ${FILE} && ls -l ${FILE}
done
The above will create your list of files, then the 'for' loop will loop through those files one at a time, look for 'include' in the file and if it finds it, do an 'ls -l' on the file.
cd /somedir
find . -type f >> filelist
for FILE in $(< filelist)
do
grep -iq include ${FILE} && ls -l ${FILE}
done
The above will create your list of files, then the 'for' loop will loop through those files one at a time, look for 'include' in the file and if it finds it, do an 'ls -l' on the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 06:32 AM
тАО10-27-2010 06:32 AM
Re: check files for embedded code.
Hi:
Patrick's solution is an excellent one. I would change:
# find . -type f >> filelist
...to:
# find . -type f > filelist
...however, so that multiple invocations of the script don't mix new results into old ones.
Remember that if you have multiple directories to search you can stack them like:
# find /home /usr/local . -type f -print
Regards!
...JRF...
Patrick's solution is an excellent one. I would change:
# find . -type f >> filelist
...to:
# find . -type f > filelist
...however, so that multiple invocations of the script don't mix new results into old ones.
Remember that if you have multiple directories to search you can stack them like:
# find /home /usr/local . -type f -print
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-28-2010 12:21 AM
тАО10-28-2010 12:21 AM
Re: check files for embedded code.
>Patrick: for FILE in $(< filelist)
Hmm, it appears this scheme isn't limited to ARG_MAX bytes, about 2 Mb. I've just done 65 Mb.
If you have more files than this, you'll need to use xargs or while:
find . -type f | while read FILE; do
grep -iq include ${FILE} && ls -l ${FILE}
done
Also if you don't want to find "included", you can add "-w" to the grep.
Hmm, it appears this scheme isn't limited to ARG_MAX bytes, about 2 Mb. I've just done 65 Mb.
If you have more files than this, you'll need to use xargs or while:
find . -type f | while read FILE; do
grep -iq include ${FILE} && ls -l ${FILE}
done
Also if you don't want to find "included", you can add "-w" to the grep.
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP