<?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: shell scripts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854351#M94367</link>
    <description>hi,&lt;BR /&gt;&lt;BR /&gt;I try to work without context ...&lt;BR /&gt;&lt;BR /&gt;I can't understand the meaning of first sed line, because basically it's supposed to substitute something by ... the same thing ! The &amp;amp; char is usually used with something else, for example :&lt;BR /&gt;&lt;BR /&gt;sed 's/xxx/&amp;lt; &amp;amp; &amp;gt;/g'&lt;BR /&gt;&lt;BR /&gt;would have changed all occurences of xxx in &amp;lt; xxx &amp;gt; (multiple changes on same lines by adding a final g, else sed go to next line after first replacement.&lt;BR /&gt;&lt;BR /&gt;So, first instruction doesn't seem very useful, try with or without it, it's the same ...&lt;BR /&gt;&lt;BR /&gt;then '2,$ d' would suppress all lines after line 1, so 'line' or 'head -1' would have done it quicker.&lt;BR /&gt;&lt;BR /&gt;then right += length($0); would add length of input record to variable 'right', but in your case, with 1 record only, '=' would have been enough ...&lt;BR /&gt;&lt;BR /&gt;And it finally prints the lenght of the record and the record itself.&lt;BR /&gt;&lt;BR /&gt;If you cat a file into this script, same result would be obtained by :&lt;BR /&gt;&lt;BR /&gt;VAR=$(line)&lt;BR /&gt;echo ${#VAR} $VAR&lt;BR /&gt;&lt;BR /&gt;Regards</description>
    <pubDate>Thu, 28 Nov 2002 16:19:14 GMT</pubDate>
    <dc:creator>Jean-Louis Phelix</dc:creator>
    <dc:date>2002-11-28T16:19:14Z</dc:date>
    <item>
      <title>shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854349#M94365</link>
      <description>i'm a beginner for sed n awk,so i can't reali understand what those means:&lt;BR /&gt;&lt;BR /&gt;sed 's/'"$1"'/&amp;amp;/g&lt;BR /&gt;2,$ d' |&lt;BR /&gt;awk ' {&lt;BR /&gt;         right += length($0);&lt;BR /&gt;   print right, $0;&lt;BR /&gt;       }'&lt;BR /&gt;&lt;BR /&gt;help from anyone is highly appreciated...&lt;BR /&gt;thank you...</description>
      <pubDate>Thu, 28 Nov 2002 15:57:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854349#M94365</guid>
      <dc:creator>Alice_4</dc:creator>
      <dc:date>2002-11-28T15:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854350#M94366</link>
      <description>Where did you get the code? Do you have any idea what the input is?&lt;BR /&gt;&lt;BR /&gt;It's usually necessary to see the entire picture, not just what's in the box.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 28 Nov 2002 16:01:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854350#M94366</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-11-28T16:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854351#M94367</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;I try to work without context ...&lt;BR /&gt;&lt;BR /&gt;I can't understand the meaning of first sed line, because basically it's supposed to substitute something by ... the same thing ! The &amp;amp; char is usually used with something else, for example :&lt;BR /&gt;&lt;BR /&gt;sed 's/xxx/&amp;lt; &amp;amp; &amp;gt;/g'&lt;BR /&gt;&lt;BR /&gt;would have changed all occurences of xxx in &amp;lt; xxx &amp;gt; (multiple changes on same lines by adding a final g, else sed go to next line after first replacement.&lt;BR /&gt;&lt;BR /&gt;So, first instruction doesn't seem very useful, try with or without it, it's the same ...&lt;BR /&gt;&lt;BR /&gt;then '2,$ d' would suppress all lines after line 1, so 'line' or 'head -1' would have done it quicker.&lt;BR /&gt;&lt;BR /&gt;then right += length($0); would add length of input record to variable 'right', but in your case, with 1 record only, '=' would have been enough ...&lt;BR /&gt;&lt;BR /&gt;And it finally prints the lenght of the record and the record itself.&lt;BR /&gt;&lt;BR /&gt;If you cat a file into this script, same result would be obtained by :&lt;BR /&gt;&lt;BR /&gt;VAR=$(line)&lt;BR /&gt;echo ${#VAR} $VAR&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 28 Nov 2002 16:19:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854351#M94367</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2002-11-28T16:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854352#M94368</link>
      <description>hi harry,&lt;BR /&gt;i get this code from the net when i'm searching  for some notes on sed codes. i can't understand so i post it up.&lt;BR /&gt;anyway thanks for your help.&lt;BR /&gt;i really have no idea about this code...</description>
      <pubDate>Fri, 29 Nov 2002 04:52:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripts/m-p/2854352#M94368</guid>
      <dc:creator>Alice_4</dc:creator>
      <dc:date>2002-11-29T04:52:13Z</dc:date>
    </item>
  </channel>
</rss>

