<?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: Quick awk question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957607#M788488</link>
    <description>This might fix it.&lt;BR /&gt;&lt;BR /&gt;I can't test it for you b/c I can't get that awk expression to work at all.  But assuming that it works (you got output in your example), the easiest way I know to make multiline output "collect" into a single line is to define the whole thing as a function, see below.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awkit()&lt;BR /&gt;{&lt;BR /&gt;for user in $(awk -F"\t" '{ print $2 }' input)&lt;BR /&gt;do&lt;BR /&gt;echo $user&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;awkit $1 $2 $3 $4 $5 $6 $7 $8 $9 &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 06 Feb 2006 11:53:43 GMT</pubDate>
    <dc:creator>TwoProc</dc:creator>
    <dc:date>2006-02-06T11:53:43Z</dc:date>
    <item>
      <title>Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957604#M788485</link>
      <description>i have an file with&lt;BR /&gt;aaa   ab abc abd abcde abds # space is tab&lt;BR /&gt;and a script&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;for user in $(awk -F"\t" '{ print $2 }' input)&lt;BR /&gt;do&lt;BR /&gt;echo $user&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;but the output is &lt;BR /&gt;ab&lt;BR /&gt;abc &lt;BR /&gt;abd &lt;BR /&gt;abcde &lt;BR /&gt;abds&lt;BR /&gt;&lt;BR /&gt;when I run it from the command line it comes out the way I want it&lt;BR /&gt;ab abc abd abcde abds&lt;BR /&gt;&lt;BR /&gt;Two questions&lt;BR /&gt;1. Why does the format change? &lt;BR /&gt;2. How do I fix it? I thought it was a path issue but it seems that is not the case.&lt;BR /&gt;3. $(awk -F"\t" '{ print $2 }' input | sort)&lt;BR /&gt;doest not work in the script either but it works from the command line.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Richard&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 11:34:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957604#M788485</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2006-02-06T11:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957605#M788486</link>
      <description>echo \c $user&lt;BR /&gt;?</description>
      <pubDate>Mon, 06 Feb 2006 11:48:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957605#M788486</guid>
      <dc:creator>Gavin Clarke</dc:creator>
      <dc:date>2006-02-06T11:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957606#M788487</link>
      <description>You don't need the -F"\t" - will work with space or tab.&lt;BR /&gt;&lt;BR /&gt;$2 is ab - that is all that should be printed....&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 06 Feb 2006 11:50:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957606#M788487</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-06T11:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957607#M788488</link>
      <description>This might fix it.&lt;BR /&gt;&lt;BR /&gt;I can't test it for you b/c I can't get that awk expression to work at all.  But assuming that it works (you got output in your example), the easiest way I know to make multiline output "collect" into a single line is to define the whole thing as a function, see below.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awkit()&lt;BR /&gt;{&lt;BR /&gt;for user in $(awk -F"\t" '{ print $2 }' input)&lt;BR /&gt;do&lt;BR /&gt;echo $user&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;awkit $1 $2 $3 $4 $5 $6 $7 $8 $9 &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 11:53:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957607#M788488</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2006-02-06T11:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957608#M788489</link>
      <description>BTW, when I "fix" the awk expression, I get what Geoff got - just "ab".</description>
      <pubDate>Mon, 06 Feb 2006 11:55:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957608#M788489</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2006-02-06T11:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957609#M788490</link>
      <description>If I assume that your file is named "input" and if it consists of a single line of &lt;TAB&gt; separated fields then you should only have a single line of output "ab" because the awk will only return $2 from 1 line of input.&lt;BR /&gt;&lt;BR /&gt;Since you didn't indicate what you wanted it to do I don't know how to tell you to fix it.&lt;BR /&gt;&lt;BR /&gt;I suspect the file "input" is not exactly as you described. Please post this output:&lt;BR /&gt;&lt;BR /&gt;od -Ad -tc -v input&lt;BR /&gt;&lt;BR /&gt;&lt;/TAB&gt;</description>
      <pubDate>Mon, 06 Feb 2006 11:56:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957609#M788490</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-02-06T11:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957610#M788491</link>
      <description>&lt;BR /&gt;Richard,&lt;BR /&gt;&lt;BR /&gt;Is your input file a single line with tab-seperated columns?&lt;BR /&gt;Or does it have multipel lines.&lt;BR /&gt;&lt;BR /&gt;I have the feeling you need something along the lines of:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk '{i=0; while (i++ &amp;lt; NF) {print $i}}'  input | sort&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 12:08:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957610#M788491</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-06T12:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957611#M788492</link>
      <description>Hi everyone I guess this is not a quick awk question :)&lt;BR /&gt;&lt;BR /&gt;FIle tab-seperated&lt;BR /&gt;sedi6s   sedi6a sedi6s ssdi0s zabcd9a abcder1&lt;BR /&gt;sedi6a   sedi6z sedi6a ssdi0d zabcd9x abcder9&lt;BR /&gt;&lt;BR /&gt;# od -Ad -tc -v input&lt;BR /&gt;0000000    s   e   d   i   6   s  \t   s   e   d   i   6   a       s   e&lt;BR /&gt;0000016    d   i   6   s       s   s   d   i   0   s       z   a   b   c&lt;BR /&gt;0000032    d   9   a       a   b   c   d   e   r   1  \n   s   e   d   i&lt;BR /&gt;0000048    6   a  \t   s   e   d   i   6   z       s   e   d   i   6   a&lt;BR /&gt;0000064        s   s   d   i   0   d       z   a   b   c   d   9   x&lt;BR /&gt;0000080    a   b   c   d   e   r   9  \n&lt;BR /&gt;0000088&lt;BR /&gt;&lt;BR /&gt;This is the output from the command line&lt;BR /&gt;#awk -F"\t" '{ print $2 }' input&lt;BR /&gt;sedi6a sedi6s ssdi0s zabcd9a abcder1&lt;BR /&gt;sedi6z sedi6a ssdi0d zabcd9x abcder9&lt;BR /&gt;&lt;BR /&gt;and would like the same format out of the script.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Richard</description>
      <pubDate>Mon, 06 Feb 2006 13:00:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957611#M788492</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2006-02-06T13:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957612#M788493</link>
      <description>The tab didnt show in my post so I will replace where the tab with \t.&lt;BR /&gt;&lt;BR /&gt;FIle tab-seperated&lt;BR /&gt;sedi6s\t sedi6a sedi6s ssdi0s zabcd9a abcder1&lt;BR /&gt;sedi6a\t sedi6z sedi6a ssdi0d zabcd9x abcder9</description>
      <pubDate>Mon, 06 Feb 2006 13:02:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957612#M788493</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2006-02-06T13:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957613#M788494</link>
      <description>I really can't see how you are getting that...on my system, command line or script only prints the 2nd field - whether I use \t or not:&lt;BR /&gt;&lt;BR /&gt;# awk -F"\t" '{ print $2 }' file&lt;BR /&gt;sedi6a&lt;BR /&gt;sedi6z&lt;BR /&gt;&lt;BR /&gt;# awk '{ print $2 }' file&lt;BR /&gt;sedi6a&lt;BR /&gt;sedi6z&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 13:09:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957613#M788494</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-06T13:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957614#M788495</link>
      <description>Okay - now I see - only 1 tab....&lt;BR /&gt;&lt;BR /&gt;So, basically, you want to print out the rest of the line - after the first tab...&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 06 Feb 2006 13:18:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957614#M788495</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-06T13:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957615#M788496</link>
      <description>Hi Richard:&lt;BR /&gt;&lt;BR /&gt;OK.  I seems that you have specified a tab character as your shell's IFS.&lt;BR /&gt;&lt;BR /&gt;If I do:&lt;BR /&gt;&lt;BR /&gt;# IFS=&lt;TAB&gt;&lt;BR /&gt;# for user in $(awk -F"\t" '{ print $2 }' input)&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; echo $user&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;&lt;BR /&gt;Using your *last* file descriptino, I get your output exactly as you descibe at commandline, but not in the script.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;/TAB&gt;</description>
      <pubDate>Mon, 06 Feb 2006 13:20:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957615#M788496</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-06T13:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957616#M788497</link>
      <description>Just don't do the for statement...&lt;BR /&gt;&lt;BR /&gt;# cat file.awk&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;awk -F"\t" '{ print $2 }' input&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 13:21:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957616#M788497</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-06T13:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957617#M788498</link>
      <description>The awk statement, when run at the command line is producing the correct output when the field sep is a tab, and only the first whitespace is a tab in the input file.&lt;BR /&gt;&lt;BR /&gt;The "for" loop in script is parsing the input (from awk) at each whitespace.&lt;BR /&gt;&lt;BR /&gt;Replace the "for" loop with something like&lt;BR /&gt;&lt;BR /&gt;user=$(awk -F\t '{print $2}' input)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 13:26:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957617#M788498</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2006-02-06T13:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957618#M788499</link>
      <description>&lt;BR /&gt;Looks like a confusion between who gets to pick up the tab as seperator: the shell or awk.&lt;BR /&gt;&lt;BR /&gt;You might want to make that explicit by bringing it into the awk program:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN {FS="\t"} { print $2 }' input&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN {FS="\011"} { print $2 }' input&lt;BR /&gt;&lt;BR /&gt;For next time...&lt;BR /&gt;&lt;BR /&gt;1) - That 'od' output helped a lot.&lt;BR /&gt;2) - just attach sample input, tabs and all, as a .TXT file.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 13:27:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957618#M788499</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-06T13:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957619#M788500</link>
      <description>....or, if the objective is to trim off the first "field" and sort, either&lt;BR /&gt;&lt;BR /&gt;awk -F"\t" '{print $2}' input | sort&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;cut -f 2 input | sort&lt;BR /&gt;&lt;BR /&gt;should get it.</description>
      <pubDate>Mon, 06 Feb 2006 16:17:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957619#M788500</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2006-02-06T16:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957620#M788501</link>
      <description>Well, basically you lied to us --- which is why I wanted the od output. Only the first argument is tab separated. Since it appeats that you want everything except the first argument loaded into ${user} then this should work.&lt;BR /&gt;&lt;BR /&gt;awk -F "\t" '{print $2}' input | while read user&lt;BR /&gt;  do&lt;BR /&gt;    echo "${user}"&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;The Shell's read command will load any remianing values into the last variable. In your case, since you are reading just 1 variable, all of the remaining tokens on the input line are loaded into the single variable, user.&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 16:33:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957620#M788501</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-02-06T16:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Quick awk question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957621#M788502</link>
      <description>That was it Mr. Clay..&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Richard&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 17:10:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-awk-question/m-p/4957621#M788502</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2006-02-06T17:10:39Z</dc:date>
    </item>
  </channel>
</rss>

