<?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 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489595#M214670</link>
    <description>how about a cryptic sed :)&lt;BR /&gt; &lt;BR /&gt;sed 's;\(..:..:.. \)\(.*\)\(../../..\)$;\2;' yourfile&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
    <pubDate>Mon, 21 Feb 2005 01:40:21 GMT</pubDate>
    <dc:creator>Thierry Poels_1</dc:creator>
    <dc:date>2005-02-21T01:40:21Z</dc:date>
    <item>
      <title>awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489591#M214666</link>
      <description>I am using awk to extract the 2nd column (a list of file names) out of a file like this:&lt;BR /&gt;&lt;BR /&gt;07:37:46 file1.txt 02/12/06&lt;BR /&gt;07:35:48 file 2.txt 02/12/06&lt;BR /&gt;07:36:55 file3.txt 02/12/06&lt;BR /&gt;&lt;BR /&gt;If you notice the 2nd record has a space as part of the file name so awk is treating this as a field separator.. Is there a way to get awk to include the space so I get the entire file name extracted in the 2nd record?</description>
      <pubDate>Sun, 20 Feb 2005 19:43:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489591#M214666</guid>
      <dc:creator>KT_4</dc:creator>
      <dc:date>2005-02-20T19:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489592#M214667</link>
      <description>try - awk '{print $2,$3}' infile &amp;gt; outfile</description>
      <pubDate>Sun, 20 Feb 2005 20:16:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489592#M214667</guid>
      <dc:creator>Robert Bennett_3</dc:creator>
      <dc:date>2005-02-20T20:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489593#M214668</link>
      <description>Hi KT,&lt;BR /&gt;&lt;BR /&gt;Since you text file has lines with common words "txt" and "file",&lt;BR /&gt;&lt;BR /&gt;you can change your file to do a global replacement with a comma in front of file and after txt. To modify vi the file and do this&lt;BR /&gt;:1,$s/file/,file/g and then save the file&lt;BR /&gt;Then again :1,$s/txt/txt,/g and save the file.&lt;BR /&gt;&lt;BR /&gt;Eg:-&lt;BR /&gt;Original file conntents&lt;BR /&gt;07:37:46 file1.txt 02/12/06&lt;BR /&gt;07:35:48 file 2.txt 02/12/06&lt;BR /&gt;07:36:55 file3.txt 02/12/06&lt;BR /&gt;&lt;BR /&gt;The modified file contents&lt;BR /&gt;07:37:46 ,file1.txt, 02/12/06&lt;BR /&gt;07:35:48 ,file 2.txt, 02/12/06&lt;BR /&gt;07:36:55 ,file3.txt, 02/12/06&lt;BR /&gt;&lt;BR /&gt;Now you can use awk to list he files names as follows.&lt;BR /&gt;awk -F, '{ print $2 }' filename&lt;BR /&gt;&lt;BR /&gt;This will output the file names.&lt;BR /&gt;file1.txt&lt;BR /&gt;file 2.txt&lt;BR /&gt;file3.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Indira A&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Feb 2005 01:02:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489593#M214668</guid>
      <dc:creator>Indira Aramandla</dc:creator>
      <dc:date>2005-02-21T01:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489594#M214669</link>
      <description>hai, &lt;BR /&gt;&lt;BR /&gt;we can do as,&lt;BR /&gt;&lt;BR /&gt;# cat &amp;gt; testfile&lt;BR /&gt;07:37:46 file1.txt 02/12/06&lt;BR /&gt;07:35:48 file 2.txt 02/12/06&lt;BR /&gt;07:36:55 file3.txt 02/12/06&lt;BR /&gt;&lt;BR /&gt;# awk '{ if (NF==4) { print $2$3 } else { print $2 } }' testfile&lt;BR /&gt;file1.txt&lt;BR /&gt;file2.txt&lt;BR /&gt;file3.txt&lt;BR /&gt;&lt;BR /&gt;it will check that if a input line is containing 4 fields then it will add 2nd and 3rd. Else it will display only 2nd.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Feb 2005 01:12:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489594#M214669</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-02-21T01:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489595#M214670</link>
      <description>how about a cryptic sed :)&lt;BR /&gt; &lt;BR /&gt;sed 's;\(..:..:.. \)\(.*\)\(../../..\)$;\2;' yourfile&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
      <pubDate>Mon, 21 Feb 2005 01:40:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489595#M214670</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2005-02-21T01:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489596#M214671</link>
      <description>Hi.&lt;BR /&gt;&lt;BR /&gt;I prefer to think a little before answer. I assume the following:&lt;BR /&gt;&lt;BR /&gt;a) first field is ALWAYS a timestamp in the format HH:MM:SS&lt;BR /&gt;b) last field is ALWAYS a date in the format xx/yy/zz...&lt;BR /&gt;then first and last fields won't contain blanks.&lt;BR /&gt;&lt;BR /&gt;c) everything between first and last fields is a file name.&lt;BR /&gt;&lt;BR /&gt;My first proposal would be:&lt;BR /&gt;&lt;BR /&gt;awk '{ NAME=""; for(i=2; i&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;It works fine if blank chars in file name are single (i.e. not more than one blank) and file name doesn't begin nor end in blank chars -- I assume that JUST a blank char is used as separator in the original line.&lt;BR /&gt;&lt;BR /&gt;A better proposal will remove the first field  (plus a blank char after it) and last field (plus a blank char befor it) from the original line... leaving alone the file name.</description>
      <pubDate>Mon, 21 Feb 2005 03:01:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489596#M214671</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2005-02-21T03:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489597#M214672</link>
      <description>Assuming your file is in /tmp/testfile:&lt;BR /&gt;&lt;BR /&gt;cat /tmp/testfile | while read a&lt;BR /&gt;do&lt;BR /&gt; templength=`echo $a | wc -m`&lt;BR /&gt; let length=templength-10&lt;BR /&gt; echo $a | cut -c10-$length&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This assumes that you always have a time record at the start and date record at the end (both are always the same length and the script strips the front and end 10 characters).&lt;BR /&gt;&lt;BR /&gt;All the best - Keith</description>
      <pubDate>Mon, 21 Feb 2005 03:19:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489597#M214672</guid>
      <dc:creator>Keith Bryson</dc:creator>
      <dc:date>2005-02-21T03:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489598#M214673</link>
      <description>my ultimate proposal is:&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt; LINE=$0  # needed to preserve original line and fields. &lt;BR /&gt; sub("^[[:blank:]]*" $1 ".", "", LINE) # remove first field plus a separator char&lt;BR /&gt;&lt;BR /&gt; sub("." $NF "[[:blank:]]*$", "", LINE) # remove a separator char plus last field&lt;BR /&gt;&lt;BR /&gt; print LINE&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;one doubt: I'm not sure if char class [[:blank:]] is more suitable than [[:space:]].</description>
      <pubDate>Mon, 21 Feb 2005 03:23:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489598#M214673</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2005-02-21T03:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489599#M214674</link>
      <description>Why be AWKward? I have always found AWK syntax to be tortuously finnicky and impossible to remember, and I have always found that there is another way (usually built-in to ksh) that does the same thing in a much easier &amp;amp; friendlier way:&lt;BR /&gt;read a line from your file into a variable (in this case, ${line}) then let ksh do it:&lt;BR /&gt;&lt;BR /&gt;temp=${line#* }&lt;BR /&gt;fname=${temp% *}&lt;BR /&gt;&lt;BR /&gt;This works whether or not there is a space in the filename on $line</description>
      <pubDate>Mon, 21 Feb 2005 06:46:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489599#M214674</guid>
      <dc:creator>Gordon  Morrison</dc:creator>
      <dc:date>2005-02-21T06:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489600#M214675</link>
      <description>yep, nice one.&lt;BR /&gt; &lt;BR /&gt;while read line &lt;BR /&gt;do&lt;BR /&gt;  temp=${line#* }&lt;BR /&gt;  fname=${temp% *}&lt;BR /&gt;  echo $fname&lt;BR /&gt;done &amp;lt; tt&lt;BR /&gt; &lt;BR /&gt;10 points to Gordon.</description>
      <pubDate>Mon, 21 Feb 2005 07:09:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489600#M214675</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2005-02-21T07:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489601#M214676</link>
      <description>Simple, (almost) human readable perl version would be:&lt;BR /&gt;&lt;BR /&gt;perl -e 'while (@input=split(" ",&lt;STDIN&gt;)) {&lt;BR /&gt;        shift @input;&lt;BR /&gt;        pop @input;&lt;BR /&gt;        print join(" ",@input);&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;(put it in an array, drop the first and last element and join it again.)&lt;/STDIN&gt;</description>
      <pubDate>Mon, 21 Feb 2005 09:40:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489601#M214676</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2005-02-21T09:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489602#M214677</link>
      <description>Since your lines are all well formed with that 'time &lt;SPACE&gt; name &lt;SPACE&gt; date' format, a simple REGexpr will grab the name:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;perl -ne 'print "$1\n" if (/\d\d\s+(.*)\s+\d\d/)' x&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This says:&lt;BR /&gt;\d\d\s+ = find from two decimals an whitespace&lt;BR /&gt;(\.*) = remember all&lt;BR /&gt;\s+\d\d = untill whitespace followed by two decimals is seen.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;/SPACE&gt;&lt;/SPACE&gt;</description>
      <pubDate>Mon, 21 Feb 2005 14:30:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489602#M214677</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-02-21T14:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489603#M214678</link>
      <description>Hi,&lt;BR /&gt;Perhaps no easy solution, can there be more then one whitespace and , does the names always begin with "file" and end with txt. Probably not.&lt;BR /&gt;&lt;BR /&gt;How is the input file created ? Is it possible to change the filed separator from space to tab. If it is, then it is easy to change the spaces to "_" using tr (and there will always be only 3 fields).</description>
      <pubDate>Mon, 21 Feb 2005 14:41:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489603#M214678</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2005-02-21T14:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489604#M214679</link>
      <description>Thank you all who replied!</description>
      <pubDate>Tue, 22 Feb 2005 18:06:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489604#M214679</guid>
      <dc:creator>KT_4</dc:creator>
      <dc:date>2005-02-22T18:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489605#M214680</link>
      <description>Lets say the entry data was the following:&lt;BR /&gt;"time         filename     date&lt;BR /&gt;07:37:46 file1.txt 02/12/06&lt;BR /&gt;07:35:48 file2.txt 02/12/06&lt;BR /&gt;07:36:55 file3.txt 02/12/06&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;We want to only pull out the filenames wihtout the header. An additional twist if your up for it, is to write out the filenames as comma separated items. &lt;BR /&gt;&lt;BR /&gt;IE: file1.txt, file2.txt, file3.txt&lt;BR /&gt;&lt;BR /&gt; I have the following:&lt;BR /&gt;&lt;BR /&gt;awk '{print $2}' | sed 's/filename//g'&lt;BR /&gt;&lt;BR /&gt;This line only removes the filename string but leaves a blank line where it was. Is it possible to completely remove the line? &lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Jun 2005 11:41:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk/m-p/3489605#M214680</guid>
      <dc:creator>Rafael Santander</dc:creator>
      <dc:date>2005-06-01T11:41:26Z</dc:date>
    </item>
  </channel>
</rss>

