<?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: Unix Grep in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459544#M703944</link>
    <description>When you said "search for a string though out my system", I thought you were talking about your entire system. You really want to search your entire "home directory" it sounds like.&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Mon, 10 Jan 2005 12:38:28 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2005-01-10T12:38:28Z</dc:date>
    <item>
      <title>Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459537#M703937</link>
      <description>&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I need to search for a string through out &lt;BR /&gt;my system. i.e as soon as i login my unix box,&lt;BR /&gt;i reach my home directory. From there , i need &lt;BR /&gt;to issue a search command which needs to search all scripts (*.sql, *.sh, *.log etc..) under all directories and sub directories.&lt;BR /&gt;&lt;BR /&gt;home_dir &amp;gt; grep "ADFH Script Failed"  &lt;SEARCH whole="" system=""&gt;&lt;BR /&gt;&lt;BR /&gt;Can anyone let me know , what command should i issue.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Jil&lt;BR /&gt;&lt;BR /&gt;&lt;/SEARCH&gt;</description>
      <pubDate>Mon, 10 Jan 2005 11:19:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459537#M703937</guid>
      <dc:creator>jilpangs</dc:creator>
      <dc:date>2005-01-10T11:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459538#M703938</link>
      <description>cd to desired starting directory; / ig desired&lt;BR /&gt;&lt;BR /&gt;TARGET="ADFH Script Failed"&lt;BR /&gt;find . -type f \( -name '*.sql' -o -name '*.sh' -o -name '*.log' \) | while read X&lt;BR /&gt;do&lt;BR /&gt;  grep -q "${TARGET}" ${X}&lt;BR /&gt;  STAT=${?}&lt;BR /&gt;  if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;    then&lt;BR /&gt;      echo "${X}"&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jan 2005 11:28:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459538#M703938</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-10T11:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459539#M703939</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I copied your script into a shell script(search.sh) and executed it from my home directory.&lt;BR /&gt;&lt;BR /&gt;It returns only "search.sh" contains the target.I know that the traget string which i mentioned is also available in one of the subdirectory, which is not returned by this script.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Jil</description>
      <pubDate>Mon, 10 Jan 2005 11:41:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459539#M703939</guid>
      <dc:creator>jilpangs</dc:creator>
      <dc:date>2005-01-10T11:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459540#M703940</link>
      <description>Is that subdirectory pointing to by a symbolic link?&lt;BR /&gt; &lt;BR /&gt;find will not traverse symbolic links unless you add the option "-follow"&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Jan 2005 11:50:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459540#M703940</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-01-10T11:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459541#M703941</link>
      <description>If you are looking to search your entire system, then change the "find" to-&lt;BR /&gt; &lt;BR /&gt;find / -type f \( -name '*.sql' -o -name '*.sh' -o -name '*.log' \) | while read X&lt;BR /&gt; &lt;BR /&gt;I am wondering why you need to search the whole "system" since you'll be re-grepping the same files over and over and wouldn't need to be.&lt;BR /&gt; &lt;BR /&gt;Anyway you could limit your search to specific directories, or at least files that with a recent modification date?&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Jan 2005 11:58:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459541#M703941</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-01-10T11:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459542#M703942</link>
      <description>The script as written will search subdirectories as well but it must find an exact match to "ADFH Script Failed"; no other pattern will be matched. Spaces and case matter. You could make the grep case-insensitive by adding a "-i" parameter to the grep.&lt;BR /&gt;&lt;BR /&gt;As with all scripting, it's best to break apart the commands to see if they are doing what you think they are. I would try the find command by itself to see if it is returning the list of files matches the criteria first.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;find . -type f \( -name '*.sql' -o -name '*.sh' -o -name '*.log' \) &lt;BR /&gt;&lt;BR /&gt;If that works then you need to look at the grep command.&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jan 2005 12:00:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459542#M703942</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-10T12:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459543#M703943</link>
      <description>I dont understand , when you say it will search again and again...&lt;BR /&gt;&lt;BR /&gt;For eg:&lt;BR /&gt;These are the directories and subdirectories in my system.&lt;BR /&gt;&lt;BR /&gt;home_dir &amp;gt; &lt;BR /&gt;home_dir/one &amp;gt; &lt;BR /&gt;home_dir/one/one_a &amp;gt; &lt;BR /&gt;home_dir/two &amp;gt; &lt;BR /&gt;home_dir/two/two_a &amp;gt; &lt;BR /&gt;&lt;BR /&gt;When i issue a search command from &lt;BR /&gt;home_dir &amp;gt;&lt;BR /&gt;It has to search home_dir &amp;gt;&lt;BR /&gt;then &lt;BR /&gt;home_dir/one &amp;gt; &lt;BR /&gt;then&lt;BR /&gt;home_dir/one/one_a &amp;gt; &lt;BR /&gt;etc......&lt;BR /&gt;&lt;BR /&gt;Why would it search again and again the same directories ?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Jil&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jan 2005 12:07:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459543#M703943</guid>
      <dc:creator>jilpangs</dc:creator>
      <dc:date>2005-01-10T12:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459544#M703944</link>
      <description>When you said "search for a string though out my system", I thought you were talking about your entire system. You really want to search your entire "home directory" it sounds like.&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Jan 2005 12:38:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459544#M703944</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-01-10T12:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459545#M703945</link>
      <description>It is almost always dumb to search from the root directory because find can place a huge load on the system especially if several are running at once. You will be much better served by specifying a more limited set of directorys hence the suggestion to cd to the desired starting directory. I often create a wrapper around the find comand to prevent find / searches by regular users.&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jan 2005 12:41:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459545#M703945</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-10T12:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459546#M703946</link>
      <description>Sorry. I didnt make it clear to all.&lt;BR /&gt;But thats my requirement. Needs to &lt;BR /&gt;search all directories and subdirectories under my home directory.&lt;BR /&gt;&lt;BR /&gt;Can anyone help with code ?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Jil</description>
      <pubDate>Mon, 10 Jan 2005 12:41:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459546#M703946</guid>
      <dc:creator>jilpangs</dc:creator>
      <dc:date>2005-01-10T12:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459547#M703947</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm not sure which file would have the string which i'm searching for. Hence i'm planning to start the search from my home directory.&lt;BR /&gt;&lt;BR /&gt;Thats why i couldnt "Limit to set of directory"&lt;BR /&gt;&lt;BR /&gt;How can limit to set of directory ?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Jil</description>
      <pubDate>Mon, 10 Jan 2005 12:58:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459547#M703947</guid>
      <dc:creator>jilpangs</dc:creator>
      <dc:date>2005-01-10T12:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459548#M703948</link>
      <description>find /dir1 /dir2 /dir3/xxx -type f ... &lt;BR /&gt;&lt;BR /&gt;This will sequentially search /dir1 (and all subdirectories) then /dir2 (abd subdirectories) then /dir3/xxx and so on.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Man find for details.&lt;BR /&gt;&lt;BR /&gt;If you are unsure, then you can simply find / but be aware of the load you are imposing on the system.&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jan 2005 13:04:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459548#M703948</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-10T13:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459549#M703949</link>
      <description>jilpangs,&lt;BR /&gt;&lt;BR /&gt;I use something similar to this when I'm looking for a text string in a list of directories. You obviously need the correct search/read permissions to do this:&lt;BR /&gt;&lt;BR /&gt;find . -follow -type f \( -name '*.sql' -o -name '*.sh' -o -name '*.log' \) -exec grep -il '&lt;REGEXP&gt;' {} \; 2&amp;gt;/dev/nu&lt;BR /&gt;&lt;BR /&gt;find&lt;BR /&gt;. :from this direction&lt;BR /&gt;&lt;BR /&gt;-follow :follow all symbolic links&lt;BR /&gt;&lt;BR /&gt;-type f :find only regular files&lt;BR /&gt;&lt;BR /&gt;\( -name ... -o \) :matching an OR of these regular expressions&lt;BR /&gt;&lt;BR /&gt;-exec :execute the following command&lt;BR /&gt;&lt;BR /&gt;grep -il '&lt;REGEXP&gt;' :grep all find results for regular expression, ignore case and print filenames to stdout&lt;BR /&gt;&lt;BR /&gt;2&amp;gt;/dev/null :stderr to /dev/null&lt;BR /&gt;&lt;BR /&gt;You can place this is a 'for' loop to execute more commands on the resulting files.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;PK&lt;BR /&gt;&lt;/REGEXP&gt;&lt;/REGEXP&gt;</description>
      <pubDate>Tue, 11 Jan 2005 11:56:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459549#M703949</guid>
      <dc:creator>Philip Kernohan</dc:creator>
      <dc:date>2005-01-11T11:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Grep</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459550#M703950</link>
      <description>&lt;BR /&gt;Do you need to 'see' the matches, or just know which files might match. Fo rthe latter:&lt;BR /&gt;&lt;BR /&gt;find . -type f \( -name '*.sql' -o -name '*.sh' -o -name '*.log' \) -exec grep -l "ADFH Script Failed" {} \;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Jan 2005 12:56:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-grep/m-p/3459550#M703950</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-01-11T12:56:46Z</dc:date>
    </item>
  </channel>
</rss>

