<?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: Pattern Searching in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796188#M81033</link>
    <description>This will get you started but it will only work on text files:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;TARGET="${1}"&lt;BR /&gt;shift&lt;BR /&gt;&lt;BR /&gt;find . -type f | 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 "File: ${X}"&lt;BR /&gt;      grep "${TARGET}" ${X}&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Use it like this:&lt;BR /&gt;1) cd to desired directory&lt;BR /&gt;2) find.sh u_lock&lt;BR /&gt;&lt;BR /&gt;This will then descend the filetree at that point and list all files which contain the target phrase and the lines.&lt;BR /&gt;</description>
    <pubDate>Wed, 28 Aug 2002 18:56:42 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2002-08-28T18:56:42Z</dc:date>
    <item>
      <title>Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796186#M81031</link>
      <description>I need to look for a particular pattern. This pattern occures in many files in different directories....&lt;BR /&gt;&lt;BR /&gt;For example;&lt;BR /&gt;Iam looking for disabled accounts in a HP trusted host. These accounts are found in /tcb/files/auth/&lt;BR /&gt;I want to search for 'u_lock' in the various files in the directories under /tcb/files/auth&lt;BR /&gt;&lt;BR /&gt;Can anybody please give me a solution since my knowledge of scripting is bad&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Aug 2002 18:48:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796186#M81031</guid>
      <dc:creator>roadrunner_1</dc:creator>
      <dc:date>2002-08-28T18:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796187#M81032</link>
      <description>From the command line with find, you can use exec or pipe to xargs:&lt;BR /&gt;&lt;BR /&gt;find /tcb/files/auth -type f -exec grep u_lock {} \;&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;find /tcb/files/auth -type f | xargs grep u_lock&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;That xargs might need some other parameter...&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Wed, 28 Aug 2002 18:55:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796187#M81032</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-08-28T18:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796188#M81033</link>
      <description>This will get you started but it will only work on text files:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;TARGET="${1}"&lt;BR /&gt;shift&lt;BR /&gt;&lt;BR /&gt;find . -type f | 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 "File: ${X}"&lt;BR /&gt;      grep "${TARGET}" ${X}&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Use it like this:&lt;BR /&gt;1) cd to desired directory&lt;BR /&gt;2) find.sh u_lock&lt;BR /&gt;&lt;BR /&gt;This will then descend the filetree at that point and list all files which contain the target phrase and the lines.&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Aug 2002 18:56:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796188#M81033</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-08-28T18:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796189#M81034</link>
      <description>find /tcb/files/auth -name '*' -exec grep -i -l u_lock' {} \; &amp;gt; /tmp/output_file &lt;BR /&gt;&lt;BR /&gt;This will find all files contained within the /tcb/files/auth directory (and any subdirectories). Notice that the wildcard * is enclosed in single quotes. The output of the find is sent to a grep with a -i (case insensitive) and -l (ell) switch. The -l swich is necessary as this causes the grep to return the name of the file in which the search text was found (as opposed to simply returning a copy of the line itself). &lt;BR /&gt;&lt;BR /&gt;In the above example, I have searched for the string 'u_lock' (note the single quotes again around the string) and sent the output to a file called /tmp/output_file. &lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 28 Aug 2002 19:02:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796189#M81034</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-08-28T19:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796190#M81035</link>
      <description>You can just go to that directory and do a simple grep:&lt;BR /&gt;# cd /tcb/files/auth&lt;BR /&gt;# cat * | grep "u_lock"&lt;BR /&gt;&lt;BR /&gt;OR for a complete search on any directory:&lt;BR /&gt;# cd dir&lt;BR /&gt;# find . -type f -depth -print -exec grep "u_lock" {} \;</description>
      <pubDate>Wed, 28 Aug 2002 19:11:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796190#M81035</guid>
      <dc:creator>Sajid_1</dc:creator>
      <dc:date>2002-08-28T19:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796191#M81036</link>
      <description>If you do it this way:&lt;BR /&gt;&lt;BR /&gt;find . -type f -depth -exec grep "u_lock" {} \; -print&lt;BR /&gt;&lt;BR /&gt;It prints only the files that had a successful grep, not all the files checked.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Marty</description>
      <pubDate>Wed, 28 Aug 2002 19:31:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796191#M81036</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-08-28T19:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796192#M81037</link>
      <description>Thanks for all your help. I have awarded points for the same....&lt;BR /&gt;&lt;BR /&gt;The best answers which solved 100% of my requirement has been awarded 10 points...&lt;BR /&gt;&lt;BR /&gt;NO POINTS WILL BE AWARDED TO THE ANSWERS POSTED HEREAFTER....</description>
      <pubDate>Wed, 28 Aug 2002 19:51:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796192#M81037</guid>
      <dc:creator>roadrunner_1</dc:creator>
      <dc:date>2002-08-28T19:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pattern Searching</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796193#M81038</link>
      <description>Hi roadrunner,&lt;BR /&gt;&lt;BR /&gt;be careful with those "grep"s onto binary files!&lt;BR /&gt;&lt;BR /&gt;cd /dir-to-start-from&lt;BR /&gt;find . -type f -print |&lt;BR /&gt;while read name; do&lt;BR /&gt;case "$(file $name)" in&lt;BR /&gt;*text*) grep "u_lock" $name /dev/null ;;&lt;BR /&gt;esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This will only try to "grep" onto textfiles... Imagine running one of the *other* find/grep combinations, and there would be a file containing the binary codes to lock your keyboard close to "u_lock" (or some even more dangerous combinations, like instructing your terminal to *believe* you have just entered "rm -rf /* \n" or such)!&lt;BR /&gt;&lt;BR /&gt;N/A=0 points, please (as announced), but I do want you  to be careful ;-)&lt;BR /&gt; &lt;BR /&gt;Wodisch</description>
      <pubDate>Wed, 28 Aug 2002 20:28:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-searching/m-p/2796193#M81038</guid>
      <dc:creator>Wodisch_1</dc:creator>
      <dc:date>2002-08-28T20:28:32Z</dc:date>
    </item>
  </channel>
</rss>

