<?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: script help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349808#M13499</link>
    <description>Thanks all for the great tips, sorry it took so long to get back to this, had to quell some fires. &lt;BR /&gt;&lt;BR /&gt;I was able to implement Hein's solution without issue, and is working as intended. I also liked Muthukumar's, what I was initially looking for, but for some reason I couldn't get my username var to pass into the sed portion. Works great on the command line, but not in my script. Have to play with it more and figure it out, but it's a great one liner! &lt;BR /&gt;&lt;BR /&gt;Thanks all! &lt;BR /&gt;&lt;BR /&gt;CH</description>
    <pubDate>Fri, 13 Aug 2004 17:24:39 GMT</pubDate>
    <dc:creator>Chris H_3</dc:creator>
    <dc:date>2004-08-13T17:24:39Z</dc:date>
    <item>
      <title>script help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349803#M13494</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I use a script that does some clean up when users are removed from the system, and sends an email to various people with info. Now we have a bunch of single column lists that these usernames might be in also. I'm looking for a way to remove the names from those lists also, automagically! &lt;BR /&gt;&lt;BR /&gt;I can find the files the name is in with:&lt;BR /&gt;find /dir/*.txt -exec grep -l 'username' {} \;&lt;BR /&gt;&lt;BR /&gt;but can't think of a way to chain that with the removal of the username. I thought of piping that through a "grep -v 'username' &amp;gt; something" and overwriting the same files so I don't have to do a 'mv filename.tmp filename', etc, but just can't get it. &lt;BR /&gt;&lt;BR /&gt;It of course doesn't have to be one line, but that's more challanging. :) &lt;BR /&gt;&lt;BR /&gt;Thanks for any assistance!&lt;BR /&gt;&lt;BR /&gt;CH</description>
      <pubDate>Wed, 04 Aug 2004 17:13:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349803#M13494</guid>
      <dc:creator>Chris H_3</dc:creator>
      <dc:date>2004-08-04T17:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349804#M13495</link>
      <description>Sed:&lt;BR /&gt;&lt;BR /&gt;sed -ne '/[^username]/p' &amp;lt; file &amp;gt; file.new &amp;amp;&amp;amp; mv file.new file&lt;BR /&gt;&lt;BR /&gt;Awk:&lt;BR /&gt;&lt;BR /&gt;awk '!/^username$/' &amp;lt; file &amp;gt; file.new &amp;amp;&amp;amp; mv file.new file&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Aug 2004 00:50:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349804#M13495</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2004-08-05T00:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349805#M13496</link>
      <description>You could pipe your output into rm.&lt;BR /&gt;&lt;BR /&gt;I rarely do that, because there is no recycle bin in Linux.&lt;BR /&gt;&lt;BR /&gt;I redirect the find to a file and:&lt;BR /&gt;&lt;BR /&gt;while read -r filename&lt;BR /&gt;do&lt;BR /&gt;  mv $filename $filename.dat&lt;BR /&gt;done &amp;lt; input filelist&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thats a good script device and follow on.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 05 Aug 2004 01:14:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349805#M13496</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-08-05T01:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349806#M13497</link>
      <description>you can change the result file with out using temporary file or mv command as like,&lt;BR /&gt;&lt;BR /&gt; --- test file ---&lt;BR /&gt; user1&lt;BR /&gt; bye for now&lt;BR /&gt; ----------------&lt;BR /&gt; &lt;BR /&gt; echo `sed -e '/^user1/!d' testfile` &amp;gt;testfile&lt;BR /&gt;&lt;BR /&gt; To simultaneously do it,&lt;BR /&gt;&lt;BR /&gt; find $PWD/* -exec grep -l 'user1' {} \; | awk '{ print "echo `sed -e '/[^user1$]/\!d' "$1"` &amp;gt; "$1 }' | sh&lt;BR /&gt;&lt;BR /&gt; It will change the contents of every file listed out there without user1 in that &lt;BR /&gt;&lt;BR /&gt; Use user1 without username.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Aug 2004 01:39:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349806#M13497</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-08-05T01:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349807#M13498</link>
      <description>Here is an addaption of a perl script I used for similar jobs.&lt;BR /&gt;&lt;BR /&gt;It assumes data in the Megabyte range, not Gigabytes as it sucks up the files.&lt;BR /&gt;Should be close to your needs.&lt;BR /&gt;Only changes the files that need changing.&lt;BR /&gt;Only reads the files once.&lt;BR /&gt;Renames to old files away, just in case.&lt;BR /&gt;&lt;BR /&gt;$test = shift @ARGV;&lt;BR /&gt;die "Must provide line to look for" unless $test;&lt;BR /&gt;$dir = shift @ARGV;&lt;BR /&gt;foreach $file (&amp;lt;${dir}*.txt&amp;gt;) {&lt;BR /&gt;  $files++;&lt;BR /&gt;  open (F, "&amp;lt; $file");&lt;BR /&gt;  while (&lt;F&gt;) {&lt;BR /&gt;    if (/^$test$/) {&lt;BR /&gt;      $need_new = 1;&lt;BR /&gt;      $changes++;&lt;BR /&gt;      } else {&lt;BR /&gt;      push @lines, $_;&lt;BR /&gt;      }&lt;BR /&gt;    }&lt;BR /&gt;  close (F);&lt;BR /&gt;  if ($need_new) {&lt;BR /&gt;     $need_new = 0;&lt;BR /&gt;     rename $file, $file . ".old";&lt;BR /&gt;     open (F, "&amp;gt; $file") or die "Can not create new file $file";&lt;BR /&gt;     foreach (@lines) { print F $_ };&lt;BR /&gt;     close (F);&lt;BR /&gt;     undef @lines;&lt;BR /&gt;     }&lt;BR /&gt;  }&lt;BR /&gt;print "$changes lines removed from $files files.\n";&lt;/F&gt;</description>
      <pubDate>Thu, 05 Aug 2004 10:36:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349807#M13498</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-08-05T10:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349808#M13499</link>
      <description>Thanks all for the great tips, sorry it took so long to get back to this, had to quell some fires. &lt;BR /&gt;&lt;BR /&gt;I was able to implement Hein's solution without issue, and is working as intended. I also liked Muthukumar's, what I was initially looking for, but for some reason I couldn't get my username var to pass into the sed portion. Works great on the command line, but not in my script. Have to play with it more and figure it out, but it's a great one liner! &lt;BR /&gt;&lt;BR /&gt;Thanks all! &lt;BR /&gt;&lt;BR /&gt;CH</description>
      <pubDate>Fri, 13 Aug 2004 17:24:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3349808#M13499</guid>
      <dc:creator>Chris H_3</dc:creator>
      <dc:date>2004-08-13T17:24:39Z</dc:date>
    </item>
  </channel>
</rss>

