<?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: Cut column in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338112#M343103</link>
    <description>awk '{print $2}' |head -1</description>
    <pubDate>Thu, 15 Jan 2009 08:10:01 GMT</pubDate>
    <dc:creator>Venkatesh BL</dc:creator>
    <dc:date>2009-01-15T08:10:01Z</dc:date>
    <item>
      <title>Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338109#M343100</link>
      <description>I have a file , there are many lines , the content is as below . &lt;BR /&gt;&lt;BR /&gt;p.s. the "------" is space &lt;BR /&gt;&lt;BR /&gt;aaaaaa ------------------ testing1  ----------------- bbbb&lt;BR /&gt;aaaaa -----------------testing2 ----------bbbba&lt;BR /&gt;aaaaaaaaa ---------------testing3 -------------------------------------------- bbbd&lt;BR /&gt;aaaa -----------------testing4--bbbb&lt;BR /&gt;"&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;I would like to have a script to cut the content in the file to get the result , my desired result is as below&lt;BR /&gt;&lt;BR /&gt;testing1&lt;BR /&gt;testing2&lt;BR /&gt;testing3&lt;BR /&gt;testing4&lt;BR /&gt;"&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;the condition to cut the content is &lt;BR /&gt;1.  cut the content from the column 10 of each line &lt;BR /&gt;2.  each line must be ended with a word that begins with bbb  , so cut the content until bbb &lt;BR /&gt;3. erase all space ( -------- ) , then get the below result &lt;BR /&gt;&lt;BR /&gt;testing1&lt;BR /&gt;testing2&lt;BR /&gt;testing3&lt;BR /&gt;testing4&lt;BR /&gt;"&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could advise the script ? thx in advance.</description>
      <pubDate>Thu, 15 Jan 2009 07:30:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338109#M343100</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-15T07:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338110#M343101</link>
      <description>try awk '{print $2}' filename</description>
      <pubDate>Thu, 15 Jan 2009 07:57:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338110#M343101</guid>
      <dc:creator>john123</dc:creator>
      <dc:date>2009-01-15T07:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338111#M343102</link>
      <description>Sorry , I have an adjustment , what I want now is only do the first line of the file  ( instead of cut the content of each line ) , so the result should be "testing1" .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thx</description>
      <pubDate>Thu, 15 Jan 2009 07:58:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338111#M343102</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-15T07:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338112#M343103</link>
      <description>awk '{print $2}' |head -1</description>
      <pubDate>Thu, 15 Jan 2009 08:10:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338112#M343103</guid>
      <dc:creator>Venkatesh BL</dc:creator>
      <dc:date>2009-01-15T08:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338113#M343104</link>
      <description>thx reply ,&lt;BR /&gt;&lt;BR /&gt;awk '{print $2}' |head -1        &lt;BR /&gt;&lt;BR /&gt;the above script is simple , but in my case , the words "testing1" is only example ,  in real case , it is a string that have space in it ( not just a word ) ,  so if I want to cut the culumn from column 2 to second last 2 column , what can i do ? thx</description>
      <pubDate>Thu, 15 Jan 2009 08:42:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338113#M343104</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-15T08:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338114#M343105</link>
      <description>&lt;!--!*#--&gt;&amp;gt; the condition [...] is [...]&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  Sorry , I have an adjustment, [...]&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] in real case [...]&lt;BR /&gt;&lt;BR /&gt;Come back when you know what you want?&lt;BR /&gt;&lt;BR /&gt;I'm not sure that the problem is well&lt;BR /&gt;specified, but something like the following&lt;BR /&gt;might be close to what you seek.&lt;BR /&gt;&lt;BR /&gt;bash$ echo 'aaaaaa     test ing  1   bbbb' | \&lt;BR /&gt;&amp;gt; sed -e 's/^.......... *//' -e 's/ *bbb[^ ]*$//'&lt;BR /&gt;test ing  1&lt;BR /&gt;&lt;BR /&gt;The idea was to remove the first ten&lt;BR /&gt;characters ("^..........") plus any string&lt;BR /&gt;of spaces (" *"), and then to remove the&lt;BR /&gt;spaces leading up to "bbb" (" *bbb") and any&lt;BR /&gt;non-space characters between it and the end&lt;BR /&gt;of the line ("[^ ]*$").&lt;BR /&gt;&lt;BR /&gt;(As I always say, "If you can't so it with&lt;BR /&gt;'sed', it's not worth doing.")&lt;BR /&gt;&lt;BR /&gt;If you want only one line, "man head".</description>
      <pubDate>Thu, 15 Jan 2009 09:51:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338114#M343105</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-01-15T09:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338115#M343106</link>
      <description>Sorry , please ignore the my pervious message first , I think cut column 2 ( awk '{print $2}' |head -1 )  is not work for my case .&lt;BR /&gt;&lt;BR /&gt;I would like to carify my requirement as below .&lt;BR /&gt;&lt;BR /&gt;the file content &lt;BR /&gt;==========&lt;BR /&gt;aaaaaa ------------------ testing1 ----------------- bbbb&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;step 1&lt;BR /&gt;====&lt;BR /&gt;check if the line contain the word "test" , if not , then output the result "Do nothing" . &lt;BR /&gt;&lt;BR /&gt;if have , then do step 2 . &lt;BR /&gt;&lt;BR /&gt;step 2&lt;BR /&gt;====&lt;BR /&gt;cut the column from column 10 to last 10 column&lt;BR /&gt;&lt;BR /&gt;so the result is &lt;BR /&gt;&lt;BR /&gt;--------------- testing1 ------------&lt;BR /&gt;&lt;BR /&gt;step 3&lt;BR /&gt;====&lt;BR /&gt;erase all space that in front of and in rear of the string "testing1" .&lt;BR /&gt;&lt;BR /&gt;so the result is &lt;BR /&gt;&lt;BR /&gt;testing</description>
      <pubDate>Thu, 15 Jan 2009 10:33:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338115#M343106</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-15T10:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338116#M343107</link>
      <description>&amp;gt;  Sorry , please ignore [...]&lt;BR /&gt;&lt;BR /&gt;Will do.  You're not paying enough to get&lt;BR /&gt;me to chase your ever-changing requirements.&lt;BR /&gt;I've provided a "sed" example which does&lt;BR /&gt;much of what you want (even now).  If you&lt;BR /&gt;can't find someone to write your script for&lt;BR /&gt;you, perhaps you should try to study that&lt;BR /&gt;example, and adapt it to your (latest) needs.</description>
      <pubDate>Thu, 15 Jan 2009 17:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338116#M343107</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-01-15T17:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338117#M343108</link>
      <description>thx reply ,&lt;BR /&gt;&lt;BR /&gt;the my last message would be my final requirement ( sorry to change requirement as I get something confused ) , I will change it again. &lt;BR /&gt;&lt;BR /&gt;I tried   sed -e 's/^.......... *//' -e 's/ *bbb[^ ]*$//'&lt;BR /&gt;&lt;BR /&gt;the result is &lt;BR /&gt;--------------- testing1 -----------------&lt;BR /&gt;&lt;BR /&gt;if I want to cut column as the my message , could advise what can i do ?  thx</description>
      <pubDate>Fri, 16 Jan 2009 01:13:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338117#M343108</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-16T01:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338118#M343109</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I tried sed -e 's/^.......... *//' -e 's/ *bbb[^ ]*$//'&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; the result is&lt;BR /&gt;&amp;gt; --------------- testing1 -----------------&lt;BR /&gt;&lt;BR /&gt;I don't see how it could be.  As I showed&lt;BR /&gt;before, I don't get those spaces.&lt;BR /&gt;&lt;BR /&gt;Now, if they were tabs and not spaces, that&lt;BR /&gt;could change things.  Of course, I can't see&lt;BR /&gt;what's really in your file, and there's no&lt;BR /&gt;reason to believe that you know what's in&lt;BR /&gt;there, either, and my psychic powers are too&lt;BR /&gt;weak to tell me, so I don't see what more I&lt;BR /&gt;can do.</description>
      <pubDate>Fri, 16 Jan 2009 05:28:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338118#M343109</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-01-16T05:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338119#M343110</link>
      <description>Please attach a file or explain better what you want to do.  Specify the exact columns you want to extract and in your attachment provide the result.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;from column 10 to last 10 column&lt;BR /&gt;&lt;BR /&gt;I'm not sure what "to last 10 column" means?</description>
      <pubDate>Fri, 16 Jan 2009 05:54:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338119#M343110</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-01-16T05:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338120#M343111</link>
      <description>thx dennis ,&lt;BR /&gt;&lt;BR /&gt;sorry to confused you , I attached a file , could please provide advise ? if still not clear , please point it out , I will explain more detail .&lt;BR /&gt;&lt;BR /&gt;thx</description>
      <pubDate>Fri, 16 Jan 2009 07:02:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338120#M343111</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-16T07:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338121#M343112</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I attached a file, could please provide advise?&lt;BR /&gt;&amp;gt;that mean erase the character that from column 1 to 10 and from column 60 to 70&lt;BR /&gt;&lt;BR /&gt;I assumed you wanted to just keep columns 11 to 60.  And only wanted to remove the 10 columns from 61 to 70.&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;BEGIN {&lt;BR /&gt;getline&lt;BR /&gt;if ($0 ~ /aaaa/) {&lt;BR /&gt;   str = substr($0, 11, 61-11)&lt;BR /&gt;#   print str&lt;BR /&gt;   sub("^ *", "", str) # strip leading spaces&lt;BR /&gt;#   print str&lt;BR /&gt;   sub(" *$", "", str) # strip trailing spaces&lt;BR /&gt;   print str&lt;BR /&gt;} else {&lt;BR /&gt;   print "Do nothing"&lt;BR /&gt;}&lt;BR /&gt;exit&lt;BR /&gt;} ' file</description>
      <pubDate>Fri, 16 Jan 2009 08:58:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338121#M343112</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-01-16T08:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338122#M343113</link>
      <description>it works for almost all the requirement ,&lt;BR /&gt;&lt;BR /&gt;but what I hope to do is not to cut the column from column 60 to 70 , what I want is to cut the last ten column ( in the example , 60 -70 is last ten column , in real case , the length of the line is variable ) , could advise how to change it ? thx</description>
      <pubDate>Fri, 16 Jan 2009 09:19:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338122#M343113</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-16T09:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338123#M343114</link>
      <description>Looks like you are expecting others to do your job! :)&lt;BR /&gt;&lt;BR /&gt;I would urge you to appreciate the folks who've helped you thus far, by assigning points. Refer to &lt;A href="http://forums11.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;</description>
      <pubDate>Fri, 16 Jan 2009 09:23:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338123#M343114</guid>
      <dc:creator>Venkatesh BL</dc:creator>
      <dc:date>2009-01-16T09:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338124#M343115</link>
      <description>&amp;gt;what I want is to cut the last ten column&lt;BR /&gt;&lt;BR /&gt;Why didn't you say exactly that.  You said "to last 10 column", which (to) doesn't go together.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;(60 - 70 is last ten column&lt;BR /&gt;&lt;BR /&gt;No your edge arithmetic is wrong, last 11 columns.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;could advise how to change it?&lt;BR /&gt;&lt;BR /&gt;Trivial:&lt;BR /&gt;str = substr($0, 11, length($0)-2*10)&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2009 10:04:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338124#M343115</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-01-16T10:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338125#M343116</link>
      <description>thx reply ,&lt;BR /&gt;&lt;BR /&gt;It run perfectly .&lt;BR /&gt;I still have one more question , the str is the result of the script , but it only output the result in the loop , can advise how to make the str result as a variable of the script ? like the below , I added echo $str at the end of it ( after exit )  , how to let it output the result of str ? thx &lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;BEGIN {&lt;BR /&gt;getline&lt;BR /&gt;if ($0 ~ /aaaa/) {&lt;BR /&gt;   str = substr($0, 11, 61-11)&lt;BR /&gt;#   print str&lt;BR /&gt;   sub("^ *", "", str) # strip leading spaces&lt;BR /&gt;#   print str&lt;BR /&gt;   sub(" *$", "", str) # strip trailing spaces&lt;BR /&gt;   print str&lt;BR /&gt;} else {&lt;BR /&gt;   print "Do nothing"&lt;BR /&gt;}&lt;BR /&gt;exit&lt;BR /&gt;} ' file&lt;BR /&gt;&lt;BR /&gt;echo $str</description>
      <pubDate>Wed, 21 Jan 2009 03:08:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338125#M343116</guid>
      <dc:creator>heaman1</dc:creator>
      <dc:date>2009-01-21T03:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cut column</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338126#M343117</link>
      <description>&lt;!--!*#--&gt;&amp;gt;can advise how to make the str result as a variable of the script?&lt;BR /&gt;&lt;BR /&gt;It might be better to use Steven's sed solution.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;how to let it output the result of str?&lt;BR /&gt;&lt;BR /&gt;You wrap it in $():&lt;BR /&gt;str=$(awk '&lt;BR /&gt;BEGIN {&lt;BR /&gt;getline&lt;BR /&gt;if ($0 ~ /aaaa/) {&lt;BR /&gt;   str = substr($0, 11, length($0)-2*10)&lt;BR /&gt;   sub("^ *", "", str) # strip leading spaces&lt;BR /&gt;   sub(" *$", "", str) # strip trailing spaces&lt;BR /&gt;   print str&lt;BR /&gt;} else {&lt;BR /&gt;   print "Do nothing"&lt;BR /&gt;}&lt;BR /&gt;exit&lt;BR /&gt;} ' file)&lt;BR /&gt;&lt;BR /&gt;If our answers were helpful, please read the following about assigning points:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;.. assigned points to 0 of 56 responses&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/pageList.do?userId=WW165205&amp;amp;listType=unassigned&amp;amp;forumId=1" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/pageList.do?userId=WW165205&amp;amp;listType=unassigned&amp;amp;forumId=1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you don't assign points, you run the risk of being struck off.</description>
      <pubDate>Wed, 21 Jan 2009 03:55:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-column/m-p/4338126#M343117</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-01-21T03:55:05Z</dc:date>
    </item>
  </channel>
</rss>

