<?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 question in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964562#M101378</link>
    <description>Hmm,&lt;BR /&gt;&lt;BR /&gt;Your question talks about adding a line after a recognized line, but the numbers in the code attempt suggest the line should go before.&lt;BR /&gt;&lt;BR /&gt;Merijn has the smart solution with a replace of 'nothing' with a new line and then have the implied (-p) print, print out the double-line string.&lt;BR /&gt;&lt;BR /&gt;To KISS, i like your 'just print first, then see if you need to print more'.&lt;BR /&gt;&lt;BR /&gt;This works for me on XP (where I needed to escape quotes):&lt;BR /&gt;&lt;BR /&gt;#  perl  -n -ix -e "print; print \"192.168.1.4 \myhost4\n\" if /^192.168.1.3/" tmp.txt&lt;BR /&gt;#  type tmp.txt&lt;BR /&gt;192.168.1.1 myhost1&lt;BR /&gt;192.168.1.2 myhost2&lt;BR /&gt;192.168.1.3 myhost3&lt;BR /&gt;192.168.1.4 myhost4&lt;BR /&gt;192.168.1.10 myhost10&lt;BR /&gt;&lt;BR /&gt;Under an hpux shell that should probably be:&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e 'print; print "192.168.1.4 \myhos4\n" if /^192.168.1.3/' tmp.txt&lt;BR /&gt;&lt;BR /&gt;The "192.168.1.3" at the begin-of-line had better be unique enough. &lt;BR /&gt;Merijn's match is more exact, allowing for any whitespace between the number and name.&lt;BR /&gt;The problem with your solution may have the whitespace, but that's invisible (sic) in this forum presentation. They \s+ instead of spaces next time.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
    <pubDate>Sat, 04 Mar 2006 10:53:06 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2006-03-04T10:53:06Z</dc:date>
    <item>
      <title>perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964560#M101376</link>
      <description>perl -i -n -e 'print $_; print "192.168.1.3 \myhost3\n" if /^192.168.4 \myhost4/;' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;I'm trying to get this work, search for an existed line and add right below it in the /etc/hosts file in sequence?&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;192.168.1.1  myhost1&lt;BR /&gt;192.168.1.2  myhost2&lt;BR /&gt;192.168.1.3  myhost3&lt;BR /&gt;&lt;NEW line=""&gt;&lt;BR /&gt;192.168.1.10 myhost10&lt;BR /&gt;&lt;BR /&gt;10 points for the best solution&lt;/NEW&gt;</description>
      <pubDate>Sat, 04 Mar 2006 00:57:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964560#M101376</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-04T00:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964561#M101377</link>
      <description>perl -pi -e 'm/^192.168.1.4\s+myhost4/ and s/$/\n192.168.1.3\tmyhost3' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 04 Mar 2006 01:55:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964561#M101377</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-04T01:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964562#M101378</link>
      <description>Hmm,&lt;BR /&gt;&lt;BR /&gt;Your question talks about adding a line after a recognized line, but the numbers in the code attempt suggest the line should go before.&lt;BR /&gt;&lt;BR /&gt;Merijn has the smart solution with a replace of 'nothing' with a new line and then have the implied (-p) print, print out the double-line string.&lt;BR /&gt;&lt;BR /&gt;To KISS, i like your 'just print first, then see if you need to print more'.&lt;BR /&gt;&lt;BR /&gt;This works for me on XP (where I needed to escape quotes):&lt;BR /&gt;&lt;BR /&gt;#  perl  -n -ix -e "print; print \"192.168.1.4 \myhost4\n\" if /^192.168.1.3/" tmp.txt&lt;BR /&gt;#  type tmp.txt&lt;BR /&gt;192.168.1.1 myhost1&lt;BR /&gt;192.168.1.2 myhost2&lt;BR /&gt;192.168.1.3 myhost3&lt;BR /&gt;192.168.1.4 myhost4&lt;BR /&gt;192.168.1.10 myhost10&lt;BR /&gt;&lt;BR /&gt;Under an hpux shell that should probably be:&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e 'print; print "192.168.1.4 \myhos4\n" if /^192.168.1.3/' tmp.txt&lt;BR /&gt;&lt;BR /&gt;The "192.168.1.3" at the begin-of-line had better be unique enough. &lt;BR /&gt;Merijn's match is more exact, allowing for any whitespace between the number and name.&lt;BR /&gt;The problem with your solution may have the whitespace, but that's invisible (sic) in this forum presentation. They \s+ instead of spaces next time.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Mar 2006 10:53:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964562#M101378</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-03-04T10:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964563#M101379</link>
      <description>Hein, that last command will print every line twice.&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e 'print; print "192.168.1.4 \myhos4\n" if /^192.168.1.3/' tmp.txt&lt;BR /&gt;&lt;BR /&gt;should be either&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e '/^192.168.1.3/ and print "192.168.1.4 \myhos4\n"' tmp.txt&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e 'print "192.168.1.4 \myhos4\n" if /^192.168.1.3/' tmp.txt&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# perl -ni -e 'print; print "192.168.1.4 \myhos4\n" if /^192.168.1.3/' tmp.txt&lt;BR /&gt;&lt;BR /&gt;Guess which one I would prefer :)&lt;BR /&gt;&lt;BR /&gt;AND they are not safe, as they also match lines that start with 192.168.1.33&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 04 Mar 2006 11:09:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964563#M101379</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-04T11:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964564#M101380</link>
      <description>for which all the first two insert the new line before the match and the third does what Hein suggested. Sorry for this.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 04 Mar 2006 11:12:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964564#M101380</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-04T11:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964565#M101381</link>
      <description>Procura,&lt;BR /&gt;&lt;BR /&gt;Your first reply return this:&lt;BR /&gt;Substitution replacement not terminated at -e line 1.&lt;BR /&gt;&lt;BR /&gt;perl -pi -e 'm/^192.168.1.4\s+myhost4/ and s/$/\n192.168.1.3\tmyhost3'/etc/hosts&lt;BR /&gt;&lt;BR /&gt;Hein,&lt;BR /&gt;&lt;BR /&gt;As procura said, your solution print 2 lines which create duplicate entries. &lt;BR /&gt;&lt;BR /&gt;The only issue here as Procura mentioned it doesn't differentiate between the uniq names?&lt;BR /&gt;&lt;BR /&gt;perl -ni -e 'print; print "192.168.1.4 \tmyhos4\n" if /^192.168.1.3/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;cat /etc/hosts&lt;BR /&gt;192.168.1.1     myhost1&lt;BR /&gt;192.168.1.2     myhost2&lt;BR /&gt;192.168.1.3     myhost3&lt;BR /&gt;192.168.1.4     myhos4 &lt;NOT uniq=""&gt;&lt;BR /&gt;192.168.1.10    myhost10&lt;BR /&gt;192.168.1.33    myhost33 &lt;NOT uniq=""&gt;&lt;BR /&gt;192.168.1.4     myhos4&lt;BR /&gt;192.168.1.37    myhost37 &lt;NOT uniq=""&gt;&lt;BR /&gt;192.168.1.4     myhos4&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/NOT&gt;&lt;/NOT&gt;&lt;/NOT&gt;</description>
      <pubDate>Sat, 04 Mar 2006 16:14:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964565#M101381</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-04T16:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964566#M101382</link>
      <description>perl -pi -e 'm/^192.168.1.4\s+myhost4/ and s/$/\n192.168.1.3\tmyhost3/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;formatting isn't ITRC's best point.&lt;BR /&gt;trailing slash was missing after myhost3&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 04 Mar 2006 17:18:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964566#M101382</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-04T17:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964567#M101383</link>
      <description>Second problem: anchor&lt;BR /&gt;&lt;BR /&gt;perl -ni -e 'print; print "192.168.1.4 \tmyhos4\n" if /^192.168.1.3\b/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 04 Mar 2006 17:20:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964567#M101383</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-04T17:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964568#M101384</link>
      <description>Procura,&lt;BR /&gt;&lt;BR /&gt;I did add "/" before I post my last reply but nothing happened? Have you tried it yourself?&lt;BR /&gt;perl -pi -e 'm/^192.168.1.4\s+myhost4/ and s/$/\n192.168.1.3\tmyhost3/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This one worked like a charm!&lt;BR /&gt;perl -ni -e 'print; print "192.168.1.4 \tmyhos4\n" if /^192.168.1.3\b/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can this be done with AWK and SED?&lt;BR /&gt;&lt;BR /&gt;Where do you go to find these flags? any links for quick reference guide will be appreciated!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Mar 2006 18:23:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964568#M101384</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-04T18:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964569#M101385</link>
      <description>&lt;BR /&gt;&amp;gt;&amp;gt; Hein,&lt;BR /&gt;&amp;gt;&amp;gt; As procura said, your solution print 2 lines which create duplicate entries. &lt;BR /&gt;&lt;BR /&gt;My mistake, I somehow left a -p (which Prints $_ after each input iteration) on the line instead of the -n (which just loops over the input).&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; The only issue here as Procura mentioned &amp;gt;&amp;gt; it doesn't differentiate between the uniq names?&lt;BR /&gt;&lt;BR /&gt;Yeah, I should reply Ã­n a hurry'. To catch .3 being different from .33 the search pattern needs to be extended with something, anthying. I'd suggest simply using whitespace ( \s ) but many other options exists, like a word boundary ( \b ) or a non-digit ( \D ). &lt;BR /&gt;I would recommend against just using a simple space, because the file might legitemately have a tab as whitespace and you would not 'see' the difference.&lt;BR /&gt;In fact, this may well have been the original problem. Use ascii dump to test that: # grep "168.4" /etc/hosts | od -a&lt;BR /&gt;&lt;BR /&gt;Anyway ... the fixed up command then becomes (again untested. Sorry) ...&lt;BR /&gt;&lt;BR /&gt;perl -ni -e 'print; print "192.168.1.4 \tmyhos4\n" if /^192.168.1.3\s+/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Mar 2006 18:27:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964569#M101385</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-03-04T18:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964570#M101386</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You asked Merijun &amp;amp; Hein where you would find documentation for the various flags that control Perl's behavior.&lt;BR /&gt;&lt;BR /&gt;Complete documentation should be available with your own Perl installation.  See 'perlrun' for a discussion of Perl's flags:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://perldoc.perl.org/perlrun.html" target="_blank"&gt;http://perldoc.perl.org/perlrun.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;More generally, for the most current release:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://perldoc.perl.org/" target="_blank"&gt;http://perldoc.perl.org/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 04 Mar 2006 19:01:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964570#M101386</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-04T19:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964571#M101387</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;...with an apology to Merijn ...for misspelling his name.  I can't type today :-))&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 04 Mar 2006 19:06:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964571#M101387</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-04T19:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964572#M101388</link>
      <description>You guys are really good!&lt;BR /&gt;&lt;BR /&gt;Hein, &lt;BR /&gt;You got it! I tested it and it worked fine. &lt;BR /&gt;&lt;BR /&gt;The white spaces made more sense as I went through the link James posted.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;James,&lt;BR /&gt;&lt;BR /&gt;So if I'm going to include of perl lines in a shell script, I would specify the switches "#!" like this as per the link?&lt;BR /&gt;#!/bin/sh -- # -*- perl -*- -p&lt;BR /&gt;&lt;BR /&gt;That means perl will be executed when it's only found by the shell script. Did I understood that correctly?&lt;BR /&gt;&lt;BR /&gt;I promise to assign points at the end. It's just getting more interesting!</description>
      <pubDate>Sat, 04 Mar 2006 20:43:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964572#M101388</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-04T20:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964573#M101389</link>
      <description>Never seen that syntax&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh -- # -*- perl -*- -p&lt;BR /&gt;&lt;BR /&gt;But, once you get the hack of scripting in perl, you don't call perl from sh scripts, but write perl scripts.&lt;BR /&gt;&lt;BR /&gt;To translate your working line&lt;BR /&gt;&lt;BR /&gt;perl -ni -e 'print; print "192.168.1.4 \tmyhos4\n" if /^192.168.1.3\b/' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;to a perl script&lt;BR /&gt;--8&amp;lt;---&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;open my $f_hosts, "&amp;lt; /etc/hosts" or die "/etc/hosts: $!";&lt;BR /&gt;my @hosts = &amp;lt;$f_hosts&amp;gt;;&lt;BR /&gt;close $f_hosts;&lt;BR /&gt;@hosts or die "/etc/hosts did not return me any lines";&lt;BR /&gt;&lt;BR /&gt;open STDOUT, "&amp;gt; /etc/hosts" or die "/etc/host: $!\nprevious content:\n@hosts";&lt;BR /&gt;for (@hosts) {&lt;BR /&gt;print;&lt;BR /&gt;m/^192.168.1.3\b/ and print "192.168.1.4 \tmyhos4\n";&lt;BR /&gt;}&lt;BR /&gt;close STDOUT;&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ who hopes to have demonstrated the strength of perl's commandline options ]</description>
      <pubDate>Sun, 05 Mar 2006 03:45:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964573#M101389</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-05T03:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964574#M101390</link>
      <description>Procura,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can the same perl line be translated into awk and sed?&lt;BR /&gt;&lt;BR /&gt;Can you post good links with simple descriptions and examples for awk and sed?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2006 14:45:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964574#M101390</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-05T14:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964575#M101391</link>
      <description>my awk/sed foo is diminishing, as perl is all I need.&lt;BR /&gt;&lt;BR /&gt;Perl supports translation the other way round, which in fact was quite helpful when I learned perl.&lt;BR /&gt;&lt;BR /&gt;# a2p&lt;BR /&gt;# s2p&lt;BR /&gt;&lt;BR /&gt;are the awk2perl and sed2perl translators.&lt;BR /&gt;once you start writing scripts in perl, there is most likely no way back to awk and/or sed, as the richness of features of perl makes sed and awk want to hide behind some trees. That does by no means make me say awk/sed is bad. I use those myself still quite often, but not in script form, but only from the command line, or in shell scripts.&lt;BR /&gt;&lt;BR /&gt;For every problem unix has the right tool, and though perl can fit almost any problem, it is by no means the best tool for every problem. (though for me, knowing also about the darker corners, it comes very close).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NAME&lt;BR /&gt;       a2p - Awk to Perl translator&lt;BR /&gt;&lt;BR /&gt;SYNOPSIS&lt;BR /&gt;       a2p [options] [filename]&lt;BR /&gt;&lt;BR /&gt;DESCRIPTION&lt;BR /&gt;       A2p takes an awk script specified on the command line (or from standard&lt;BR /&gt;       input) and produces a comparable perl script on the standard output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NAME&lt;BR /&gt;       psed - a stream editor&lt;BR /&gt;&lt;BR /&gt;SYNOPSIS&lt;BR /&gt;          psed [-an] script [file ...]&lt;BR /&gt;          psed [-an] [-e script] [-f script-file] [file ...]&lt;BR /&gt;&lt;BR /&gt;          s2p  [-an] [-e script] [-f script-file]&lt;BR /&gt;&lt;BR /&gt;DESCRIPTION&lt;BR /&gt;       A stream editor reads the input stream consisting of the specified&lt;BR /&gt;       files (or standard input, if none are given), processes is line by line&lt;BR /&gt;       by applying a script consisting of edit commands, and writes resulting&lt;BR /&gt;       lines to standard output. The filename `"-"' may be used to read stanâ  &lt;BR /&gt;       dard input.&lt;BR /&gt;&lt;BR /&gt;       The edit script is composed from arguments of -e options and&lt;BR /&gt;       script-files, in the given order. A single script argument may be specâ  &lt;BR /&gt;       ified as the first parameter.&lt;BR /&gt;&lt;BR /&gt;       If this program is invoked with the name s2p, it will act as a sed-to-&lt;BR /&gt;       Perl translator. See "sed Script Translation".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For the above, I would say that the awk solution would be something like&lt;BR /&gt;&lt;BR /&gt;# awk '{print}/^192.168.1.4[ \t]/{print "192.168.1.4 myhost4"}' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;depending on the shell and your version/release of (GNU)awk, \t might not be recognized in the character class and should be replaced with a literal TAB character, often entered as Control-V TAB.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sun, 05 Mar 2006 15:02:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964575#M101391</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-03-05T15:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964576#M101392</link>
      <description>Procura,&lt;BR /&gt;&lt;BR /&gt;Few changes in awk. The TAB in the first one seem to work like whitespaces? &lt;BR /&gt;So I left it there and added \t in the second pattern.&lt;BR /&gt;&lt;BR /&gt;This worked just fine.&lt;BR /&gt;&lt;BR /&gt;awk '{print}/^192.168.1.3\t/{print "192.168.1.4\tmyhost4"}' /etc/hosts &amp;gt; /etc/hosts.tmp;cp /etc/hosts.tmp /etc/hosts&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is this book good to start with PERL?&lt;BR /&gt;&lt;A href="http://www.oreilly.com/catalog/pperl3/" target="_blank"&gt;http://www.oreilly.com/catalog/pperl3/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;It looks like it's possible to compile your code in perl?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2006 16:50:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964576#M101392</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-05T16:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964577#M101393</link>
      <description>Is this book good to start with PERL?&lt;BR /&gt;&lt;A href="http://www.oreilly.com/catalog/pperl3/" target="_blank"&gt;http://www.oreilly.com/catalog/pperl3/&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Here is a complete set, &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://unix.org.ua/orelly/perl/prog3/index.htm" target="_blank"&gt;http://unix.org.ua/orelly/perl/prog3/index.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun &lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2006 23:26:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964577#M101393</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-03-05T23:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964578#M101394</link>
      <description>LOL!</description>
      <pubDate>Sun, 05 Mar 2006 23:41:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-question/m-p/4964578#M101394</guid>
      <dc:creator>limak</dc:creator>
      <dc:date>2006-03-05T23:41:34Z</dc:date>
    </item>
  </channel>
</rss>

