<?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: Need help with awk/cut script please, formating columns in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778434#M99298</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;try the attached script, using your infile as $1&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
    <pubDate>Thu, 27 Apr 2006 08:11:30 GMT</pubDate>
    <dc:creator>john korterman</dc:creator>
    <dc:date>2006-04-27T08:11:30Z</dc:date>
    <item>
      <title>Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778429#M99293</link>
      <description>Hello,&lt;BR /&gt;I have data that is formated in columns that looks like the following(note the example data is actaully one full line the web page has wrapped it).&lt;BR /&gt;&lt;BR /&gt;11AF: 10A:1/myhost/0_3_0 10A:1/myhost/0_6_1  7A:1/myhost/0_9_0 7A:1/myhost/0_2_1&lt;BR /&gt;&lt;BR /&gt;The / tend to confuse the shell and i have characaters :, /, and space as delimiters on the same line which is making it tough to put the data into proper format.  I do not have control over the input format just as a fyi.&lt;BR /&gt;&lt;BR /&gt;The output format I am trying to get to using the above line example is as follows (the following is on one line as well):&lt;BR /&gt;&lt;BR /&gt;11AF 10A 1 myhost 0_3_0  10A 1 myhost 0_6_1 7A 1 myhost 0_9_0 7A 1 myhost 0_2_1&lt;BR /&gt;&lt;BR /&gt;I am trying to get the flow to work like.&lt;BR /&gt;for i in `cat list`&lt;BR /&gt;do&lt;BR /&gt;each formated line above is equal to a variable.&lt;BR /&gt;example a=11AF b=10A c=1 and so on.&lt;BR /&gt;This way i can generate commands line by line in with the specific variables and order with syntax in between very easily.&lt;BR /&gt;&lt;BR /&gt;Example command -someoption $b -anotheroption $a&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Apr 2006 18:27:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778429#M99293</guid>
      <dc:creator>generic_1</dc:creator>
      <dc:date>2006-04-26T18:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778430#M99294</link>
      <description>Hi Jeff:&lt;BR /&gt;&lt;BR /&gt;Perl will handle multiple characters as delimiters.  &lt;BR /&gt;&lt;BR /&gt;# X='11AF: 10A:1/myhost/0_3_0 10A:1/myhost/0_6_1 7A:1/myhost/0_9_0 7A:1/myhost/0_2_1'&lt;BR /&gt;&lt;BR /&gt;# echo ${X}|perl -nle '@a=split /[:\/]/;print "@a"'&lt;BR /&gt;&lt;BR /&gt;11AF  10A 1 myhost 0_3_0 10A 1 myhost 0_6_1 7A 1 myhost 0_9_0 7A 1 myhost 0_2_1&lt;BR /&gt;&lt;BR /&gt;If this is what you want, do:&lt;BR /&gt;&lt;BR /&gt;# perl -nle '@a=split /[:\/]/;print "@a"'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 26 Apr 2006 18:45:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778430#M99294</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-04-26T18:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778431#M99295</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Its very simple. Use the following&lt;BR /&gt;&lt;BR /&gt;cat filename | sed -e "s/:/ /g" -e "s/\// /g"&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Ninad</description>
      <pubDate>Thu, 27 Apr 2006 03:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778431#M99295</guid>
      <dc:creator>Ninad_1</dc:creator>
      <dc:date>2006-04-27T03:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778432#M99296</link>
      <description>One by one, use tr&lt;BR /&gt;echo "11AF: 10A:1/myhost/0_3_0 10A:1/myhost/0_6_1 7A:1/myhost/0_9_0 7A:1/myhost/0_2_1" | tr '\:' " " |tr '\/' " "</description>
      <pubDate>Thu, 27 Apr 2006 03:36:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778432#M99296</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2006-04-27T03:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778433#M99297</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;get rid of multiple delimiter and empty fields.&lt;BR /&gt;If you should need the original $@ after this processing, store the positional parameters into a differnt variable.&lt;BR /&gt;If your strings form lines in the file list:&lt;BR /&gt;&lt;BR /&gt;typeset -i i n=0&lt;BR /&gt;sed 's,[:/], ,g' list |&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;  ((n+=1))&lt;BR /&gt;  set $line&lt;BR /&gt;  # processing as one unit&lt;BR /&gt;  echo $line&lt;BR /&gt;  # processing of the fields&lt;BR /&gt;  for var&lt;BR /&gt;  do&lt;BR /&gt;  echo $var&lt;BR /&gt;  done&lt;BR /&gt;  # processing as a matrix&lt;BR /&gt;  i=1&lt;BR /&gt;  while [ i -le $# ]&lt;BR /&gt;  do&lt;BR /&gt;    eval print $n.$i \$$i&lt;BR /&gt;  done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Thu, 27 Apr 2006 04:14:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778433#M99297</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-04-27T04:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778434#M99298</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;try the attached script, using your infile as $1&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Thu, 27 Apr 2006 08:11:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778434#M99298</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-04-27T08:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778435#M99299</link>
      <description>Hi (again) Jeff:&lt;BR /&gt;&lt;BR /&gt;Perl's version of 'tr' will do this too, thusly:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'tr /:\/ / /s;print' filename&lt;BR /&gt;&lt;BR /&gt;[ Please copy-and-paste since the Forum is going to reduce the whitespace above ].&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 27 Apr 2006 08:37:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778435#M99299</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-04-27T08:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with awk/cut script please, formating columns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778436#M99300</link>
      <description>A different take:&lt;BR /&gt;&lt;BR /&gt;When confronted with this type of thing when I 've already got a working solution on one type of delimiter (as you do).&lt;BR /&gt;&lt;BR /&gt;Have a pre-processing pass that will unify your delimiter to one type instead of two.&lt;BR /&gt;&lt;BR /&gt;In your script before running your regular process:&lt;BR /&gt;&lt;BR /&gt;cat file1 | sed -e "s/\//:/g" &amp;gt; file1.a&lt;BR /&gt;&lt;BR /&gt;[The above changes backslashes to ":" - giving you a single delimiter that doesn't need escaping to process]&lt;BR /&gt;&lt;BR /&gt;... continue on with your program reading "file1.a" instead of "file1" - using ":" as the delimiter for parsing your variables.&lt;BR /&gt;&lt;BR /&gt;This is a "cheap" way out with the following obvious limitation:  If the file you are parsing is HUGE, then the above solution may cost you too much time, in which case there are better previous postings  to do it all it once.</description>
      <pubDate>Thu, 27 Apr 2006 09:59:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-help-with-awk-cut-script-please-formating-columns/m-p/3778436#M99300</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2006-04-27T09:59:17Z</dc:date>
    </item>
  </channel>
</rss>

