<?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: Awk Question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037468#M718971</link>
    <description>Try this sed command:&lt;BR /&gt;&lt;BR /&gt;# sed -e 's/^/-/' -e 's/-0/-/g' -e 's/-0/-/g' -e 's/^-//'  original_file &amp;gt; new_file&lt;BR /&gt;&lt;BR /&gt;Hai</description>
    <pubDate>Wed, 30 Jul 2003 16:40:09 GMT</pubDate>
    <dc:creator>Hai Nguyen_1</dc:creator>
    <dc:date>2003-07-30T16:40:09Z</dc:date>
    <item>
      <title>Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037464#M718967</link>
      <description>I have a large list of telcom point codes which I am trying to format with awk. A point code (telecom) looks like the following:&lt;BR /&gt;&lt;BR /&gt;002-345-067&lt;BR /&gt;&lt;BR /&gt;Each point code will have three sections, each three numbers in length. Does anyone know of a good way in awk to remove the leading zeros of each of the fields so that the above point code would look like the following:&lt;BR /&gt;&lt;BR /&gt;2-345-67&lt;BR /&gt;&lt;BR /&gt;However I would want:&lt;BR /&gt;&lt;BR /&gt;000-000-000&lt;BR /&gt;&lt;BR /&gt;to be returned as:&lt;BR /&gt;&lt;BR /&gt;0-0-0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Jul 2003 15:55:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037464#M718967</guid>
      <dc:creator>Michael Brennan</dc:creator>
      <dc:date>2003-07-30T15:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037465#M718968</link>
      <description>You can split the code into 3 parts, then use printf to&lt;BR /&gt;print it the way you want.&lt;BR /&gt;&lt;BR /&gt;echo 002-345-067 | awk '{split($0, a, /-/); printf "%d-%d-%d\n", a[1], a[2], a[3]}'&lt;BR /&gt;2-345-67&lt;BR /&gt;&lt;BR /&gt;echo 000-000-000 | awk '{split($0, a, /-/); printf "%d-%d-%d\n", a[1], a[2], a[3]}'&lt;BR /&gt;0-0-0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Jul 2003 16:22:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037465#M718968</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2003-07-30T16:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037466#M718969</link>
      <description>Set the fild separator FS="-" and then&lt;BR /&gt;use the printf statement&lt;BR /&gt;&lt;BR /&gt;printf "%d","s","s","%d","%d", $1 "-" $2 "-" $3</description>
      <pubDate>Wed, 30 Jul 2003 16:26:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037466#M718969</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2003-07-30T16:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037467#M718970</link>
      <description>You can do with sed like this.&lt;BR /&gt;cat &lt;FILE&gt; | sed -e 's/[0]\{1,2\}\([0-9]\)/\1/g'&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Michael.&lt;/FILE&gt;</description>
      <pubDate>Wed, 30 Jul 2003 16:27:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037467#M718970</guid>
      <dc:creator>Michael Kelly_5</dc:creator>
      <dc:date>2003-07-30T16:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037468#M718971</link>
      <description>Try this sed command:&lt;BR /&gt;&lt;BR /&gt;# sed -e 's/^/-/' -e 's/-0/-/g' -e 's/-0/-/g' -e 's/^-//'  original_file &amp;gt; new_file&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Wed, 30 Jul 2003 16:40:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037468#M718971</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-07-30T16:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037469#M718972</link>
      <description>pc03:/tmp/xx 507 $ echo "001-000003-43253-22" | perl -pe's/(\d+)/$1+0/ge'&lt;BR /&gt;1-3-43253-22&lt;BR /&gt;pc03:/tmp/xx 508 $&lt;BR /&gt;&lt;BR /&gt;or in your case, change all in file and replace file&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e's/(\d+)/$1+0/ge' infile&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Wed, 30 Jul 2003 18:14:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037469#M718972</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-07-30T18:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037470#M718973</link>
      <description>I like this one:&lt;BR /&gt;&lt;BR /&gt;cat $file | awk '{FS="-"; printf("%d-%d-%d\n",$1,$2,$3)}' &amp;gt; $new_file&lt;BR /&gt;&lt;BR /&gt;Nice and clean.</description>
      <pubDate>Wed, 30 Jul 2003 19:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037470#M718973</guid>
      <dc:creator>Ronelle van Niekerk</dc:creator>
      <dc:date>2003-07-30T19:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037471#M718974</link>
      <description>use following script&lt;BR /&gt;$1 is your code&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset -i g1 g2 g3&lt;BR /&gt;echo $1 | tr "-" " " | read g1 g2 g3 &amp;amp;&amp;amp; echo $g1"-"$g2"-"$g3&lt;BR /&gt;&lt;BR /&gt;example : scriptname = filter&lt;BR /&gt;filter 002-345-067&lt;BR /&gt;2-345-67&lt;BR /&gt;&lt;BR /&gt;filter 000-000-000&lt;BR /&gt;0-0-0&lt;BR /&gt;Rgds,&lt;BR /&gt;Jean-Luc&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Jul 2003 08:57:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-question/m-p/3037471#M718974</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2003-07-31T08:57:26Z</dc:date>
    </item>
  </channel>
</rss>

