<?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: perl delete help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397533#M70917</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here is one way to do it.  Create a Perl script that will match a range of lines and skip them, otherwise printing the lines.  Something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl                                                                 &lt;BR /&gt;                                                                                &lt;BR /&gt;# noheader.pl                                                                   &lt;BR /&gt;                                                                                                                                                                &lt;BR /&gt;while (&amp;lt;&amp;gt;) {                                                                    &lt;BR /&gt;        if (/Received:/ .. /DeliveredDate:/) {                                  &lt;BR /&gt;                next;                                                           &lt;BR /&gt;        } else {                                                                &lt;BR /&gt;                print;                                                          &lt;BR /&gt;        }                                                                       &lt;BR /&gt;}                                                                               &lt;BR /&gt;&lt;BR /&gt;Now, just run it like this:&lt;BR /&gt;&lt;BR /&gt;./noheader.pl &amp;lt;159191.txt&lt;BR /&gt;&lt;BR /&gt;and it should just print the text you need.&lt;BR /&gt;&lt;BR /&gt;Of course, there are even shorter ways to do it.  After I played with this for a bit I figured out that this would also work:&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  print unless (/Received:/ .. /DeliveredDate:/);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 11 Oct 2004 16:01:35 GMT</pubDate>
    <dc:creator>John Poff</dc:creator>
    <dc:date>2004-10-11T16:01:35Z</dc:date>
    <item>
      <title>perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397532#M70916</link>
      <description>I have some files that I need to delete the header information.  I am new to Perl and have no idea on how to approach this.  I have attached an example of the files I am working with.  I need to be able to delete the header information starting from 'Received:' all the way up to 'DeliveredDate:'.  Can anyone please help?  Thanks</description>
      <pubDate>Mon, 11 Oct 2004 13:03:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397532#M70916</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2004-10-11T13:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397533#M70917</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here is one way to do it.  Create a Perl script that will match a range of lines and skip them, otherwise printing the lines.  Something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl                                                                 &lt;BR /&gt;                                                                                &lt;BR /&gt;# noheader.pl                                                                   &lt;BR /&gt;                                                                                                                                                                &lt;BR /&gt;while (&amp;lt;&amp;gt;) {                                                                    &lt;BR /&gt;        if (/Received:/ .. /DeliveredDate:/) {                                  &lt;BR /&gt;                next;                                                           &lt;BR /&gt;        } else {                                                                &lt;BR /&gt;                print;                                                          &lt;BR /&gt;        }                                                                       &lt;BR /&gt;}                                                                               &lt;BR /&gt;&lt;BR /&gt;Now, just run it like this:&lt;BR /&gt;&lt;BR /&gt;./noheader.pl &amp;lt;159191.txt&lt;BR /&gt;&lt;BR /&gt;and it should just print the text you need.&lt;BR /&gt;&lt;BR /&gt;Of course, there are even shorter ways to do it.  After I played with this for a bit I figured out that this would also work:&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  print unless (/Received:/ .. /DeliveredDate:/);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Oct 2004 16:01:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397533#M70917</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2004-10-11T16:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397534#M70918</link>
      <description>Thank you so much for the help.  However, I have a couple of more questions now.  When the data is printed how can I save the new output in the same file?&lt;BR /&gt;&lt;BR /&gt;In perl can I have the script to run for over 500 different files at once?  Is there a way to avoid entering the file name for every file?</description>
      <pubDate>Mon, 11 Oct 2004 21:46:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397534#M70918</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2004-10-11T21:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397535#M70919</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can use the '-i' option from the Perl command line to edit the file in place.  Something like this should work:&lt;BR /&gt;&lt;BR /&gt;perl -i -n -e 'print unless (/Received:/ .. /DeliveredDate:/);'  159191.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;There are a couple of ways to handle it with a  bunch of files.  One way would be to put the line above into a small shell script:&lt;BR /&gt;&lt;BR /&gt;for f in *.txt&lt;BR /&gt;do&lt;BR /&gt; perl -i -n -e 'print unless (/Received:/ .. /DeliveredDate:/);' $f&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You could also use the file handling machinery inside of Perl and do it in a single script.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2004 09:19:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397535#M70919</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2004-10-12T09:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397536#M70920</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I put the following in a script as you suggested:&lt;BR /&gt;&lt;BR /&gt;for $f in *.txt&lt;BR /&gt;do&lt;BR /&gt;perl -i -n -e 'print unless (/Received:/ .. /DeliveredDate:/);'$f&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I get this error message:&lt;BR /&gt;&lt;BR /&gt;'Missing $ on loop variable at test.pl line 1.'&lt;BR /&gt;&lt;BR /&gt;Am I doing something wrong?  Do I need to assign a directory where the files are located?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 13 Oct 2004 19:22:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397536#M70920</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2004-10-13T19:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397537#M70921</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It looks like you left out the space between the last single quote and the dollar f variable.&lt;BR /&gt;&lt;BR /&gt;You should be able to run this from the directory where your files are located, or else you can specify the path in the 'for' statement, like this:&lt;BR /&gt;&lt;BR /&gt;for f in /some/directory/*.txt&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 19:51:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397537#M70921</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2004-10-13T19:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397538#M70922</link>
      <description>Hello JP,&lt;BR /&gt;&lt;BR /&gt;Sorry about this I have another question.  Can I put this code in a .pl file:&lt;BR /&gt;&lt;BR /&gt;for f in *.txt&lt;BR /&gt;do&lt;BR /&gt;'print unless(/Received:/ .. /DeliveredDate:/);' $f&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;and then run it this way:&lt;BR /&gt;&lt;BR /&gt;perl -i -n -e filename.pl&lt;BR /&gt;&lt;BR /&gt;I am not sure if this is legal or not.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 23:08:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397538#M70922</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2004-10-13T23:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: perl delete help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397539#M70923</link>
      <description>Hello JP,&lt;BR /&gt;&lt;BR /&gt;Please disregard my previous message.  I got it to work.  Thank you for all your help.  You saved me!</description>
      <pubDate>Wed, 13 Oct 2004 23:25:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-delete-help/m-p/3397539#M70923</guid>
      <dc:creator>Shaf_1</dc:creator>
      <dc:date>2004-10-13T23:25:45Z</dc:date>
    </item>
  </channel>
</rss>

