- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Question using the find command -
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
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
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
тАО10-15-2005 08:35 AM
тАО10-15-2005 08:35 AM
How can I do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 08:48 AM
тАО10-15-2005 08:48 AM
Re: Question using the find command -
This will check the contents of text files and create a lsit which you can cat later or cat with a script.
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
тАО10-15-2005 09:07 AM
тАО10-15-2005 09:07 AM
Re: Question using the find command -
I don't think that's what I want to do.
Here's another tip on what I want to do.
There are several thousand files on the machine. I need to be able to find certain files amongst those several thousand and cat the results to another file.
for i in `cat /home/me/filestocatout'
do
find $i (against those devices)
cat $i (cat the found files to another file)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 10:58 AM
тАО10-15-2005 10:58 AM
Re: Question using the find command -
Now if you already have a list of known-to-be -text files, then your script would look like this:
for MYFILE in $(cat /home/me/filestocatout)
do
cat $MYFILE >> another_file
done
But if this list, filestocatout, contains untested files, your script would have to be changed to something like this:
for MYFILE in $(cat /home/me/filestocatout)
do
file $MYFILE | grep -q text
if [ $? -eq 0 ]
then
cat $MYFILE >> another_file
fi
done
It turns out that most tests in /etc/magic will return the word "text" if the file looks like it contains ASCII text.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 11:42 AM
тАО10-15-2005 11:42 AM
Re: Question using the find command -
There are approximately 4000 files total. I need to be able to search through all of these files for specific files. I would like to be able to say something like "for all of the files in the list I specify, do a find on the filename, once found, print the contents of all the files to one large text file so I can search through it for certain command strings".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 12:20 PM
тАО10-15-2005 12:20 PM
Re: Question using the find command -
find /somedirectory -type f -name "*-cw.log"
Now you always want to do the above command to determine if the files that were found are indeed the correct ones (and none are overlooked), then you can accomplish the entire task with one line:
find /somedirectory -type f -name "*-cw.log" -exec cat {} \; >> /var/tmp/bigfile
If you know what criteria you need to find within each file, you can add that to the command line:
find /somedirectory -type f -name "*-cw.log" -exec cat {} \; | grep -i -e err -e warn >> /var/tmp/bigfile
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 12:31 PM
тАО10-15-2005 12:31 PM
Re: Question using the find command -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 12:39 PM
тАО10-15-2005 12:39 PM
Re: Question using the find command -
find /somedirectory -type f -name "*-cw.log" -exec cat {} \; >> /var/tmp/bigfile
to somehow read from a file a list of device names I want to search for. For example, I may need to search for these files which is the hostname of the device with a .cfg extension-
host1.cfg
host2.cfg
host99.cfg
lcartr1.cfg
lcaswitch99.cfg
oregoncat1.cfg
oregonsw99.cfg
The hostnames of the devices don't follow a pattern so I can't say *rtr.cfg or *switch.cfg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 12:50 PM
тАО10-15-2005 12:50 PM
Re: Question using the find command -
find /somedirectory -type f -name "*.cfg" -exec cat {} \; >> /var/tmp/bigfile
If you already have a list of the filenames or perhaps a list of the hostnames, then you can use the for-do-done construct to enumerate the filenames and have find locate the specific filename.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2005 01:30 PM
тАО10-15-2005 01:30 PM
Re: Question using the find command -
How on earth would I do what you suggested by using the for-do-done constuct to enumerate the filenames and have the find locate the specific filename then write the contents of the file to largefile?