<?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: Script for capturing only few values from the first line of a file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162505#M664503</link>
    <description>How about:&lt;BR /&gt;&lt;BR /&gt;perl -ne 'print "$1\n" if /^[A-Za-z]+\.[0-9][0-9].* ([0-9][0-9]\.[0-9][0-9]\.[0-&lt;BR /&gt;9][0-9]\.11) .+ [0-1]?[0-9]\/[0-3]?[0-9]\/[0-9][0-9]$/' workfile.txt&lt;BR /&gt;</description>
    <pubDate>Tue, 10 Mar 2009 22:14:33 GMT</pubDate>
    <dc:creator>George Spencer_4</dc:creator>
    <dc:date>2009-03-10T22:14:33Z</dc:date>
    <item>
      <title>Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162503#M664501</link>
      <description>Hello,&lt;BR /&gt;I understand that this is not a scripting forum, but I believe this should be very easy for you experts.&lt;BR /&gt;&lt;BR /&gt;First line of my file contains some data like this "abcdefg.xx 123    xx.yy.zz.11 There is some variable length text here      03/10/09"&lt;BR /&gt;Note that:&lt;BR /&gt;1) where I see "123" it will never be more than 4 characters. But it can be of zero characters too. Meaning it does not exist.&lt;BR /&gt;2) Line will always end with a date, so it will contain a character "/" in it.&lt;BR /&gt;3) What I am want to extract is the value "xx.yy.zz.11 There is some variable length text here". This could be of any length, any number of words, any characters.&lt;BR /&gt;&lt;BR /&gt;Do any of you have a script/command to make this happen? Lets assume that filename is workfile.txt.</description>
      <pubDate>Tue, 10 Mar 2009 20:26:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162503#M664501</guid>
      <dc:creator>Anant</dc:creator>
      <dc:date>2009-03-10T20:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162504#M664502</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;# X="abcdefg.xx 123 xx.yy.zz.11 There is some variable length text here 03/10/09"&lt;BR /&gt;&lt;BR /&gt;# Y="abcdefg.xx xx.yy.zz.11 There is some variable length text here 03/10/09"&lt;BR /&gt;&lt;BR /&gt;# echo ${X}|perl -nle 'm{.+?\s+(\d+\s+)*(.+)} and print $2'&lt;BR /&gt;xx.yy.zz.11 There is some variable length text here 03/10/09&lt;BR /&gt;&lt;BR /&gt;...and:&lt;BR /&gt;&lt;BR /&gt;# echo ${Y}|perl -nle 'm{.+?\s+(\d+\s+)*(.+)} and print $2'&lt;BR /&gt;xx.yy.zz.11 There is some variable length text here 03/10/09&lt;BR /&gt;&lt;BR /&gt;...which distinguishes rule-1.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 10 Mar 2009 21:29:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162504#M664502</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-03-10T21:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162505#M664503</link>
      <description>How about:&lt;BR /&gt;&lt;BR /&gt;perl -ne 'print "$1\n" if /^[A-Za-z]+\.[0-9][0-9].* ([0-9][0-9]\.[0-9][0-9]\.[0-&lt;BR /&gt;9][0-9]\.11) .+ [0-1]?[0-9]\/[0-3]?[0-9]\/[0-9][0-9]$/' workfile.txt&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Mar 2009 22:14:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162505#M664503</guid>
      <dc:creator>George Spencer_4</dc:creator>
      <dc:date>2009-03-10T22:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162506#M664504</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Do any of you have a script/command to make this happen?&lt;BR /&gt;&lt;BR /&gt;You could use awk:&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt;if (length($2) &amp;gt; 4) # optional field&lt;BR /&gt;   start = 2&lt;BR /&gt;else&lt;BR /&gt;   start = 3  # skip optional field&lt;BR /&gt;printf "%s", $start&lt;BR /&gt;for (i = start+1; i &amp;lt; NF; ++i)&lt;BR /&gt;   printf " %s", $i&lt;BR /&gt;print ""&lt;BR /&gt;exit&lt;BR /&gt;}' workfile.txt.</description>
      <pubDate>Tue, 10 Mar 2009 23:22:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162506#M664504</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-03-10T23:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162507#M664505</link>
      <description>Hello Anant,&lt;BR /&gt;&lt;BR /&gt;Try this also :&lt;BR /&gt;&lt;BR /&gt;head -1 workfile.txt | sed 's/^.*123 \(.*$\)/\1/'&lt;BR /&gt;&lt;BR /&gt;If "123" is not present in the line, the commands will give the entire line&lt;BR /&gt;&lt;BR /&gt;If you need nothing when "123" is not present, insert before sed a grep command so you will have this :&lt;BR /&gt;&lt;BR /&gt;head -1 workfile.txt | grep 123 | sed 's/^.*123 \(.*$\)/\1/'&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;Roland</description>
      <pubDate>Wed, 11 Mar 2009 09:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162507#M664505</guid>
      <dc:creator>Roland Piette</dc:creator>
      <dc:date>2009-03-11T09:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162508#M664506</link>
      <description>maybe simpler &lt;BR /&gt;&lt;BR /&gt;Assuming a file named 'file' contains:&lt;BR /&gt;Please wait...checking for disk quotas&lt;BR /&gt;(c)Copyright 1983-2000 Hewlett-Packard Co.,  All Rights Reserved.&lt;BR /&gt;&lt;BR /&gt;$ line &lt;FILE&gt;&lt;/FILE&gt;$ echo $first&lt;BR /&gt;Please&lt;BR /&gt;$ echo $second&lt;BR /&gt;wait...checking for disk quotas&lt;BR /&gt;$ line &lt;FILE&gt;&lt;/FILE&gt;$ echo $first&lt;BR /&gt;Please&lt;BR /&gt;$ echo $second&lt;BR /&gt;wait...checking&lt;BR /&gt;$ echo $rest_of_line&lt;BR /&gt;for disk quotas&lt;BR /&gt;$&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Mar 2009 10:36:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162508#M664506</guid>
      <dc:creator>David DiBiase</dc:creator>
      <dc:date>2009-03-11T10:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162509#M664507</link>
      <description>Are we making this too complex?  If you are only looking for column 2 with space delimters:&lt;BR /&gt;&lt;BR /&gt;# cat foo&lt;BR /&gt;abcdefg.xx 123 xx.yy.zz.11 There is some variable length text here 03/10/09&lt;BR /&gt;abcdefg.xx 13 xx.yy.zz.11 There is some variable length text here 03/10/09&lt;BR /&gt;abcdefg.xx  xx.yy.zz.11 There is some variable length text here 03/10/09&lt;BR /&gt;abcdefg.xx 3 xx.yy.zz.11 There is some variable length text here 03/10/09&lt;BR /&gt;# cut -d\  -f2 foo&lt;BR /&gt;123&lt;BR /&gt;13&lt;BR /&gt;&lt;BR /&gt;3&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Mar 2009 19:09:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162509#M664507</guid>
      <dc:creator>Bob E Campbell</dc:creator>
      <dc:date>2009-03-11T19:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing only few values from the first line of a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162510#M664508</link>
      <description>People responding to my questions, provided the necessary solutions. Thanks to all of them.</description>
      <pubDate>Wed, 11 Mar 2009 19:15:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-only-few-values-from-the-first-line-of-a/m-p/5162510#M664508</guid>
      <dc:creator>Anant</dc:creator>
      <dc:date>2009-03-11T19:15:30Z</dc:date>
    </item>
  </channel>
</rss>

