<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Question using the find command - in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650201#M803633</link>
    <description>I have a list of filenames (aka hostnames).  I want to search through the 4000 or so files and find the files that match the list then write the contents to a file.&lt;BR /&gt;&lt;BR /&gt;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?&lt;BR /&gt;</description>
    <pubDate>Sat, 15 Oct 2005 20:30:45 GMT</pubDate>
    <dc:creator>Rob Johnson_3</dc:creator>
    <dc:date>2005-10-15T20:30:45Z</dc:date>
    <item>
      <title>Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650192#M803624</link>
      <description>I want to do a find on several text files on a system.  When the files are found I want to cat those files out and write them to a file.&lt;BR /&gt;&lt;BR /&gt;How can I do this?</description>
      <pubDate>Sat, 15 Oct 2005 15:35:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650192#M803624</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T15:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650193#M803625</link>
      <description>find / -exec grep -l 'criteria' {} \; &amp;gt; filelist&lt;BR /&gt;&lt;BR /&gt;This will check the contents of text files and create a lsit which you can cat later or cat with a script.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Sat, 15 Oct 2005 15:48:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650193#M803625</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-10-15T15:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650194#M803626</link>
      <description>I think that command will search through files for a certain string of text.  &lt;BR /&gt;&lt;BR /&gt;I don't think that's what I want to do.&lt;BR /&gt;&lt;BR /&gt;Here's another tip on what I want to do.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;for i in `cat /home/me/filestocatout'&lt;BR /&gt;do&lt;BR /&gt;find $i (against those devices)&lt;BR /&gt;cat $i (cat the found files to another file)&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Oct 2005 16:07:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650194#M803626</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T16:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650195#M803627</link>
      <description>There is no such thing in Unix as a text file (or binary file or data file, etc). In other words, all files except for special files like pipes and device files are simply files. Unlike PCs where most programs will assign suffix or extension and then use that extension to start an appropriate program, Unix does not maintain any content flag anywhere. The closest you can come to identifying a text file is to use the file command. It will actually read a portion of the file, then run through a series of tests listed in the /etc/magic file.&lt;BR /&gt; &lt;BR /&gt;Now if you already have a list of known-to-be -text files, then your script would look like this:&lt;BR /&gt; &lt;BR /&gt; for MYFILE in $(cat /home/me/filestocatout)&lt;BR /&gt; do&lt;BR /&gt; cat $MYFILE &amp;gt;&amp;gt; another_file&lt;BR /&gt; done&lt;BR /&gt; &lt;BR /&gt;But if this list, filestocatout, contains untested files, your script would have to be changed to something like this:&lt;BR /&gt; &lt;BR /&gt;for MYFILE in $(cat /home/me/filestocatout)&lt;BR /&gt; do&lt;BR /&gt; file $MYFILE | grep -q text&lt;BR /&gt; if [ $? -eq 0 ]&lt;BR /&gt; then&lt;BR /&gt; cat $MYFILE &amp;gt;&amp;gt; another_file&lt;BR /&gt; fi&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;It turns out that most tests in /etc/magic will return the word "text" if the file looks like it contains ASCII text.</description>
      <pubDate>Sat, 15 Oct 2005 17:58:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650195#M803627</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-15T17:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650196#M803628</link>
      <description>The CiscoWorks application runs on this unix box.  The configuration files for each router and switch are stored in various directories on a filesystem in text format.  &lt;BR /&gt;&lt;BR /&gt;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".</description>
      <pubDate>Sat, 15 Oct 2005 18:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650196#M803628</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T18:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650197#M803629</link>
      <description>I think you mean that the filenames are predefined ir at least have something in common like xxxx-cw.log or something similar, correct? If so, you can ask find to locate the file by using the -name option, something like this:&lt;BR /&gt; &lt;BR /&gt;find /somedirectory -type f -name "*-cw.log"&lt;BR /&gt; &lt;BR /&gt;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:&lt;BR /&gt; &lt;BR /&gt;find /somedirectory -type f -name "*-cw.log" -exec cat {} \; &amp;gt;&amp;gt; /var/tmp/bigfile&lt;BR /&gt; &lt;BR /&gt;If you know what criteria you need to find within each file, you can add that to the command line:&lt;BR /&gt; &lt;BR /&gt;find /somedirectory -type f -name "*-cw.log" -exec cat {} \; | grep -i -e err -e warn &amp;gt;&amp;gt; /var/tmp/bigfile</description>
      <pubDate>Sat, 15 Oct 2005 19:20:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650197#M803629</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-15T19:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650198#M803630</link>
      <description>do you know part of the string to be searched within the file or part of the file name required?</description>
      <pubDate>Sat, 15 Oct 2005 19:31:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650198#M803630</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2005-10-15T19:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650199#M803631</link>
      <description>OK.  How can I use the find command you gave&lt;BR /&gt;&lt;BR /&gt;find /somedirectory -type f -name "*-cw.log" -exec cat {} \; &amp;gt;&amp;gt; /var/tmp/bigfile &lt;BR /&gt;&lt;BR /&gt;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-&lt;BR /&gt;&lt;BR /&gt;host1.cfg&lt;BR /&gt;host2.cfg &lt;BR /&gt;host99.cfg&lt;BR /&gt;lcartr1.cfg&lt;BR /&gt;lcaswitch99.cfg&lt;BR /&gt;oregoncat1.cfg&lt;BR /&gt;oregonsw99.cfg&lt;BR /&gt;&lt;BR /&gt;The hostnames of the devices don't follow a pattern so I can't say *rtr.cfg or *switch.cfg</description>
      <pubDate>Sat, 15 Oct 2005 19:39:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650199#M803631</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T19:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650200#M803632</link>
      <description>I'm not clear whether your task is to find all files that end with .cfg in which case the command would be:&lt;BR /&gt; &lt;BR /&gt; find /somedirectory -type f -name "*.cfg" -exec cat {} \; &amp;gt;&amp;gt; /var/tmp/bigfile&lt;BR /&gt; &lt;BR /&gt;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.</description>
      <pubDate>Sat, 15 Oct 2005 19:50:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650200#M803632</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-15T19:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650201#M803633</link>
      <description>I have a list of filenames (aka hostnames).  I want to search through the 4000 or so files and find the files that match the list then write the contents to a file.&lt;BR /&gt;&lt;BR /&gt;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?&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Oct 2005 20:30:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650201#M803633</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T20:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650202#M803634</link>
      <description>I guess it's gonna look something like:&lt;BR /&gt;&lt;BR /&gt;for i in `cat /home/listofhosts`&lt;BR /&gt;do &lt;BR /&gt;find /somedirectory -type f -name $i -exec cat {} \; &amp;gt;&amp;gt; /var/tmp/bigfile &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Oct 2005 20:48:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650202#M803634</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T20:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650203#M803635</link>
      <description>so if you know the host names you could do this.&lt;BR /&gt;&lt;BR /&gt;Create a file with each host name in ie&lt;BR /&gt;&lt;BR /&gt;cat /home/listofhosts&lt;BR /&gt;&lt;BR /&gt;host.1&lt;BR /&gt;host.2&lt;BR /&gt;host.3&lt;BR /&gt;&lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;for i in `cat /home/listofhosts |awk '{print $1}'`&lt;BR /&gt;do&lt;BR /&gt;echo "details for host $i" &amp;gt;&amp;gt; /var/tmp/file&lt;BR /&gt;find /somedirectory -type f -name "$i.cfg" -exec cat {} \; &amp;gt;&amp;gt; /var/tmp/file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Sat, 15 Oct 2005 21:26:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650203#M803635</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2005-10-15T21:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650204#M803636</link>
      <description>Ok.  Thanks everyone for your input.  I think I can make this work.  I don't have a unix box here at home so I can't test this out until Monday.&lt;BR /&gt;&lt;BR /&gt;Again, Thank you!</description>
      <pubDate>Sat, 15 Oct 2005 21:49:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650204#M803636</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-15T21:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650205#M803637</link>
      <description>Rob,&lt;BR /&gt;&lt;BR /&gt;One small point to mention; if you are going to cat somewhere around 4000 files to /onebigfile, you better be sure you have the disk space available.  In other words, don't try to save the result in /onebigfile.  Filling up / is not good.&lt;BR /&gt;&lt;BR /&gt;Just my 2cts.&lt;BR /&gt;&lt;BR /&gt;Mark</description>
      <pubDate>Mon, 17 Oct 2005 09:05:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650205#M803637</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2005-10-17T09:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650206#M803638</link>
      <description>Rob, &lt;BR /&gt;&lt;BR /&gt;If I understand what you are trying to do I may have a better idea for you.&lt;BR /&gt;&lt;BR /&gt;You have several file names that are scattered about in a file system with 4000 other files.&lt;BR /&gt;&lt;BR /&gt;You want to find all the files with those names and cat them all into one big file.&lt;BR /&gt;&lt;BR /&gt;If thatâ  s the case, you donâ  t have to find each file individually you can just find all 4000 files once and grep out the names you are looking for and cat those files to your big file&lt;BR /&gt;&lt;BR /&gt;Find . -xdev -print | grep -e "file1"  -e "file2" | while read filename&lt;BR /&gt;Do&lt;BR /&gt;Cat $filename &amp;gt;&amp;gt; $grut.big.file&lt;BR /&gt;Done&lt;BR /&gt;&lt;BR /&gt;Or if you have many file names list them in a pattern file and user grep -f patternfile&lt;BR /&gt;&lt;BR /&gt;If thatâ  s not what you are trying to do, then ignore this post.&lt;BR /&gt;&lt;BR /&gt;H</description>
      <pubDate>Mon, 17 Oct 2005 14:51:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650206#M803638</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-10-17T14:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Question using the find command -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650207#M803639</link>
      <description>Thanks for your response.  Actually, I was able to run put a script together from the previous posts and it worked quiet well. I'm gonna stick with it.  &lt;BR /&gt;I love this forum because each time I need to do something like this, I can come here then come away with a solution.&lt;BR /&gt;&lt;BR /&gt;Again thanks for your response.</description>
      <pubDate>Mon, 17 Oct 2005 15:43:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-using-the-find-command/m-p/3650207#M803639</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-10-17T15:43:54Z</dc:date>
    </item>
  </channel>
</rss>

