- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find strings in files
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-04-2003 06:50 AM
08-04-2003 06:50 AM
I listed all tables of my databse to a file called tables.txt each table in one line and I want to know if these database tables are used in some source code. These source codes are under /tmp/source/dir_1, /tmp/source/dir__2 ... /tmp/source/dir_n. I used:
find /tmp/source -depth -print > find.log, to list all files under /tmp/source and it worked fine.
then I did:
egrep -i -n -f tables.txt find.log, to list the files that have one of my database tables in it.
But I do not know the table that is used because doing these commands I only know that one of the tables is present in the source code file listed but what table ? I really want to list the tables in tables.txt file that is used in one of the source code files.
Any ideas of how can I do it ?
Cheers,
Mauro
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2003 07:00 AM
08-04-2003 07:00 AM
Re: Find strings in files
cat find.log |
while read file
do
egrep -f tables.txt $file 1>/dev/null 2>&1
if [ $? = 0 ] ;then
print $file
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2003 07:03 AM
08-04-2003 07:03 AM
Re: Find strings in files
Change as needed.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2003 07:05 AM
08-04-2003 07:05 AM
Solution> I really want to list the tables in tables.txt file that is used
how about this:
cat find.log |
while read file
do
egrep -f tables.txt $file 1>/dev/null 2>&1
if [ $? = 0 ] ;then
print "\nTables in $file:\n"
egrep -f tables.txt $file
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2003 08:13 AM
08-04-2003 08:13 AM
Re: Find strings in files
1. You can simply go to each dir_1, dir_2 etc., i.e. cd /tmp/source/dir_1 and run a command:
egrep -f tables.txt *
2. find /tmp/source -depth -print -exec egrep -f tables.txt {} \; |more , but this will also list all the files under /tmp/source.
Elena.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2003 03:20 AM
08-05-2003 03:20 AM
Re: Find strings in files
Another way to find...
cd /tmp/source
for table in `cat tables.txt`
do
find . -type f | xargs grep $table
done
you have to give absolute path of tables.txt
Regards
VJ.