- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- General
- >
- Re: Question using the find command -
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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?
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP