<?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: Scripting help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396482#M200020</link>
    <description>Several ways depending what IDs you're trying to eliminate...&lt;BR /&gt;&lt;BR /&gt;If they are the reserved users with UID &amp;lt; 100, you can simply use awk as follows:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($3 &amp;lt; 100) print}' /etc/passwd &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;If there are specific normal user's you're talking about, you can do similar to above specifying the UIDs of those users combined with the and operator:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($3 != 250 &amp;amp;&amp;amp; $3 != 300) print}' /etc/passwd &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;or by username:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($1 != "joebob" &amp;amp;&amp;amp; $1 != "nancysue") print}' /etc/passwd &amp;gt; newfile</description>
    <pubDate>Fri, 08 Oct 2004 11:02:07 GMT</pubDate>
    <dc:creator>Jeff_Traigle</dc:creator>
    <dc:date>2004-10-08T11:02:07Z</dc:date>
    <item>
      <title>Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396477#M200015</link>
      <description>My scripting skills are woeful I'm afraid.  I generate a file that contains only a list of user id's.  Whenever I generate this file, I need to remove the same 10 user id's that always appear and leave the remaining id's.  I've been doing this manually in vi but now I need to automate the process.&lt;BR /&gt;&lt;BR /&gt;Simplest and/or most elegant and/or easiest to understand solution gets the full 10!!.</description>
      <pubDate>Fri, 08 Oct 2004 10:50:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396477#M200015</guid>
      <dc:creator>Terrence</dc:creator>
      <dc:date>2004-10-08T10:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396478#M200016</link>
      <description>grep -Ev "user1|user2|upto_10_users" "input_file" &amp;gt; new_file&lt;BR /&gt;&lt;BR /&gt;If they appear after certain line in file, then&lt;BR /&gt;&lt;BR /&gt;head -"line" inout_file OR tail -"line" input_file&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Fri, 08 Oct 2004 10:55:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396478#M200016</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-10-08T10:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396479#M200017</link>
      <description>grep -v user1 &lt;YOUFILE&gt; | grep -v user2 | grep -v user3 | ...&lt;BR /&gt;&amp;gt; &lt;YOUNEW file=""&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc&lt;BR /&gt;&lt;/YOUNEW&gt;&lt;/YOUFILE&gt;</description>
      <pubDate>Fri, 08 Oct 2004 10:57:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396479#M200017</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-10-08T10:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396480#M200018</link>
      <description># your_script_that_generates_the_list | grep -v -w -e 203 -e merijn -e skipme -e baduser -e 488 &amp;gt; zzz&lt;BR /&gt;&lt;BR /&gt;# your_script_that_generates_the_list | perl -pe's/\b(203|merijn|skipme|baduser|488)\b//g' &amp;gt;zzz&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ who doen't know if -w is supported in all grep's on your machine ]</description>
      <pubDate>Fri, 08 Oct 2004 10:59:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396480#M200018</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-10-08T10:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396481#M200019</link>
      <description>As above, but I'd also put anchors in place, eg&lt;BR /&gt;&lt;BR /&gt;grep -vE "^uid1$|^uid2$|^uid3$" file &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;The ^ and $ anchors ensure that for example removing "fred" doesn't also remove "frederick".&lt;BR /&gt;&lt;BR /&gt;If you want to edit the file in-situ, you could do: -&lt;BR /&gt;&lt;BR /&gt;ed file &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;/^uid1$&lt;BR /&gt;d&lt;BR /&gt;/^uid2$&lt;BR /&gt;d&lt;BR /&gt;/^uid23$&lt;BR /&gt;d&lt;BR /&gt;w&lt;BR /&gt;q&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;This will let you do it without a temporary "newfile".</description>
      <pubDate>Fri, 08 Oct 2004 10:59:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396481#M200019</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-08T10:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396482#M200020</link>
      <description>Several ways depending what IDs you're trying to eliminate...&lt;BR /&gt;&lt;BR /&gt;If they are the reserved users with UID &amp;lt; 100, you can simply use awk as follows:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($3 &amp;lt; 100) print}' /etc/passwd &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;If there are specific normal user's you're talking about, you can do similar to above specifying the UIDs of those users combined with the and operator:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($3 != 250 &amp;amp;&amp;amp; $3 != 300) print}' /etc/passwd &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;or by username:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($1 != "joebob" &amp;amp;&amp;amp; $1 != "nancysue") print}' /etc/passwd &amp;gt; newfile</description>
      <pubDate>Fri, 08 Oct 2004 11:02:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396482#M200020</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2004-10-08T11:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396483#M200021</link>
      <description>Oops... first one should have been &amp;gt;, not &amp;lt;</description>
      <pubDate>Fri, 08 Oct 2004 11:03:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396483#M200021</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2004-10-08T11:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396484#M200022</link>
      <description>Argh... actually &amp;gt;= with 100 as the right-hand operand... maybe I should just go home now. :)</description>
      <pubDate>Fri, 08 Oct 2004 11:04:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396484#M200022</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2004-10-08T11:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396485#M200023</link>
      <description>Can use the "uniq" funtion as well.&lt;BR /&gt;&lt;BR /&gt;cat /etc/passwd | awk -F: '{print $1, $2}' | uniq&lt;BR /&gt;&lt;BR /&gt;The uniq function will get rid of repeats</description>
      <pubDate>Fri, 08 Oct 2004 11:07:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396485#M200023</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2004-10-08T11:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396486#M200024</link>
      <description>Many thanks to all who played!&lt;BR /&gt;&lt;BR /&gt;10 points to RAC for his insanely fast and simple answer. (Doh! grep!  I know grep! Why didn't I think of that!)&lt;BR /&gt;&lt;BR /&gt;10 points to Simon for his excellent addition to the simple answer that prevented a problem that I've had in the past where too much is removed.  I'll be writing this solution down for other scripts I have as well.&lt;BR /&gt;&lt;BR /&gt;10 points to Rick who unknowingly gave me a solution to a completely different scripting problem I was mulling.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Oct 2004 11:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396486#M200024</guid>
      <dc:creator>Terrence</dc:creator>
      <dc:date>2004-10-08T11:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396487#M200025</link>
      <description>We can do with awk script as,&lt;BR /&gt;&lt;BR /&gt; awk '{ for ( i=1; i&amp;lt;=NF; i++) if ( $i != "user1" &amp;amp;&amp;amp; $i != "user2" &amp;amp;&amp;amp; $i != "user3" ) print $0 }'  &lt;INPUTFILE&gt;&lt;BR /&gt;&lt;BR /&gt; IT will give the way to get user lists except your users.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;/INPUTFILE&gt;</description>
      <pubDate>Fri, 08 Oct 2004 11:45:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396487#M200025</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-08T11:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396488#M200026</link>
      <description>Terence, not fishing for points here, but that -w option is exactly the same as the proposed anchors, only much cleaner: it means "match words only"&lt;BR /&gt;&lt;BR /&gt;And in the perl statement, I did exactly the same: \b is word bound&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 08 Oct 2004 14:27:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396488#M200026</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-10-08T14:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396489#M200027</link>
      <description>You also have the option to put the list of user ids in a file, rather than putting them in the command, which may be less prone to mistyping if you edit the script, e.g. if the list ever changes.&lt;BR /&gt;&lt;BR /&gt;So, if the list of user ids (one per line) is /tmp/uids:&lt;BR /&gt;&lt;BR /&gt;grep -Fwv -f /tmp/uids file&lt;BR /&gt;&lt;BR /&gt;should do what you want.&lt;BR /&gt;&lt;BR /&gt;(As you're dealing with fixed strings, -F is probably faster than -E).&lt;BR /&gt;&lt;BR /&gt;Andrew</description>
      <pubDate>Mon, 11 Oct 2004 07:33:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3396489#M200027</guid>
      <dc:creator>Andrew Merritt_2</dc:creator>
      <dc:date>2004-10-11T07:33:51Z</dc:date>
    </item>
  </channel>
</rss>

