<?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 search for number and extract lines below in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179380#M678486</link>
    <description>I have a subtitle in spanish version and i want to extract the timestamps from the file.Each timestamp has a unique number above it as in the attached file.&lt;BR /&gt;&lt;BR /&gt;I would like to know how to extract all the timestamps to a separate file.</description>
    <pubDate>Thu, 04 Jun 2009 14:55:33 GMT</pubDate>
    <dc:creator>Gyankr</dc:creator>
    <dc:date>2009-06-04T14:55:33Z</dc:date>
    <item>
      <title>search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179380#M678486</link>
      <description>I have a subtitle in spanish version and i want to extract the timestamps from the file.Each timestamp has a unique number above it as in the attached file.&lt;BR /&gt;&lt;BR /&gt;I would like to know how to extract all the timestamps to a separate file.</description>
      <pubDate>Thu, 04 Jun 2009 14:55:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179380#M678486</guid>
      <dc:creator>Gyankr</dc:creator>
      <dc:date>2009-06-04T14:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179381#M678487</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If your file content is only this and want to extract only the time stamp, you can simply grep it.&lt;BR /&gt;&lt;BR /&gt;#egrep "(00|01)" filename &amp;gt; outputfile</description>
      <pubDate>Thu, 04 Jun 2009 15:08:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179381#M678487</guid>
      <dc:creator>Ganesan R</dc:creator>
      <dc:date>2009-06-04T15:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179382#M678488</link>
      <description>it looks like the string "--&amp;gt;" is the common factor on these lines. So, this should work:&lt;BR /&gt;&lt;BR /&gt;grep "--&amp;gt;" myfile &amp;gt; timestamps&lt;BR /&gt;&lt;BR /&gt;if you want to remove those timestamp lines and want the rest of the file, then:&lt;BR /&gt;&lt;BR /&gt;grep -v "--&amp;gt;" myfile &amp;gt; mytrimmedfile&lt;BR /&gt;&lt;BR /&gt;hope this helps</description>
      <pubDate>Thu, 04 Jun 2009 15:08:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179382#M678488</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-06-04T15:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179383#M678489</link>
      <description>thanks to both of you.Now it gets a bit more tricky,once i have extracted those timestamps ,i want to replace these with the ones present in the english version attached.&lt;BR /&gt;&lt;BR /&gt;So what i am trying to do here is to synchronize both my english and spanish subtitles with the same timestamp.&lt;BR /&gt;&lt;BR /&gt;Thanks again.</description>
      <pubDate>Thu, 04 Jun 2009 15:22:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179383#M678489</guid>
      <dc:creator>Gyankr</dc:creator>
      <dc:date>2009-06-04T15:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179384#M678490</link>
      <description>all right then, you will need to fiddle with sed a little. But before this, you need to make sure you have the same number of subtitle frames. Otherwise this will not work.&lt;BR /&gt;&lt;BR /&gt;the construct should be something like this&lt;BR /&gt;&lt;BR /&gt;last=1305 &lt;BR /&gt;# get this number by manually editing the file &lt;BR /&gt;# and finding the last frame sequence&lt;BR /&gt;&lt;BR /&gt;i=1&lt;BR /&gt;while [ $i -le $last ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;#source is spanish file target is english below&lt;BR /&gt;&lt;BR /&gt;#find the line with timeframe&lt;BR /&gt;(( tfl=`grep -n ^$i\$ spanish|cut -d: -f1`+1 ))&lt;BR /&gt;&lt;BR /&gt;#find the timeframe&lt;BR /&gt;spanish_time=`cat spa | sed  "${tfl}!d"`&lt;BR /&gt;&lt;BR /&gt;#using sed or another tool of your choice&lt;BR /&gt;#overwrite spanish_time into english file&lt;BR /&gt;#onto the same line&lt;BR /&gt;sed "${tfl}c\&lt;BR /&gt;${spanish_time}" english &amp;gt; /tmp/tempfile.tmp&lt;BR /&gt;#this line above has problems, most probably&lt;BR /&gt;#due to contents of variable spanish_time having &lt;BR /&gt;#special characters in it&lt;BR /&gt;#this is where you need to fiddle with sed man pages and books&lt;BR /&gt;&lt;BR /&gt;mv /tmp/tempfile.tmp english&lt;BR /&gt;done # end of while loop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2009 17:23:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179384#M678490</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-06-04T17:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179385#M678491</link>
      <description>Gyankr,&lt;BR /&gt;&lt;BR /&gt;Please help us help you.&lt;BR /&gt;&lt;BR /&gt;The provided examples do NOT seem to line up.&lt;BR /&gt;My Spanish is almost non existent, but it seems to me that&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sp 12 = 00:02:18,942 --&amp;gt; 00:02:21,850&lt;BR /&gt;declarar culpable al acusado.&lt;BR /&gt;&lt;BR /&gt;Corresponds with&lt;BR /&gt;&lt;BR /&gt;En 11 : 00:02:01,350 --&amp;gt; 00:02:04,267&lt;BR /&gt;find the accused guilty.&lt;BR /&gt;&lt;BR /&gt;And &lt;BR /&gt;&lt;BR /&gt;Sp 13 = 00:02:21,935 --&amp;gt; 00:02:25,791&lt;BR /&gt;Sea cual sea su decisiÃ³n, su veredicto deberÃ¡ ser unÃ¡nime.&lt;BR /&gt;&lt;BR /&gt;Corresponds with &lt;BR /&gt;&lt;BR /&gt;En 12 = 00:02:04,353 --&amp;gt; 00:02:08,220&lt;BR /&gt;However you decide, your verdict must be unanimous.&lt;BR /&gt;&lt;BR /&gt;There NO match on the example times/sequence ever. Not even clos. The match on the simple number seems skewed by 1.&lt;BR /&gt;&lt;BR /&gt;So... what is it? Bad examples? &lt;BR /&gt;Match regardsless?&lt;BR /&gt;&lt;BR /&gt;Also... how much data can be expected?&lt;BR /&gt;For less than a million rows or so, a simple array can be build and files read in sequence.&lt;BR /&gt;&lt;BR /&gt;For more rows, or for a more performant implementation you want an implementation which reads the files more or less in lock step, perhaps 'skipping' out of sequence records.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2009 17:38:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179385#M678491</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-06-04T17:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179386#M678492</link>
      <description>worse yet....if the sequential #s are to be believed, you have more entries in the english version than the spanish.&lt;BR /&gt;&lt;BR /&gt;What I had tried was:&lt;BR /&gt;&lt;BR /&gt;given eng.txt and span.txt (provided "subtitle" files), and created eng.ts and span.ts using grep to extract the "--&amp;gt;" lines as outlined prev.&lt;BR /&gt;&lt;BR /&gt;I pasted span.ts and eng.ts thusly:&lt;BR /&gt;&lt;BR /&gt;paste -d"/" span.ts eng.ts &amp;gt; change.ts&lt;BR /&gt;&lt;BR /&gt;adding "s/" to the beginning of each line , and "/" at end, you've a file you can use w/ sed to change span to eng ts&lt;BR /&gt;&lt;BR /&gt;sed -f change.ts span.txt &amp;gt; changed.txt&lt;BR /&gt;&lt;BR /&gt;BUT you have to remove singletons at the end of the file...as apparently their isn't a one-for-one correspondence of dialog stamps in the file.....&lt;BR /&gt;&lt;BR /&gt;without some kind of correspondence, you can't rely on automated matching....</description>
      <pubDate>Thu, 04 Jun 2009 17:56:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179386#M678492</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-06-04T17:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179387#M678493</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;OK, as Hein said, the "timestamps" don't seem to match between files.  However, if we use the first line of each paragraph as a key (your unique number), then we can substitute the contents of your Spanish file with your English one as below.  If a key isn't represented in both files, nothing for that key will be reported.&lt;BR /&gt;&lt;BR /&gt;# cat ./matchup&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $file1 = shift or die "File1 expected\n";&lt;BR /&gt;my $file2 = shift or die "File2 expected\n";&lt;BR /&gt;die "Arguments must be files\n" unless -f $file1 &amp;amp;&amp;amp; -f $file2;&lt;BR /&gt;my %frame;&lt;BR /&gt;{&lt;BR /&gt;    local $/ = '';&lt;BR /&gt;    my ( $fh, @a );&lt;BR /&gt;    open( $fh, '&amp;lt;', $file1 ) or die "Can't open '$file1': $!\n";&lt;BR /&gt;    while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;        @a = split /\n/;&lt;BR /&gt;        push( @{ $frame{ $a[0] } }, () );&lt;BR /&gt;    }&lt;BR /&gt;    close $fh;&lt;BR /&gt;    open( $fh, '&amp;lt;', $file2 ) or die "Can't open '$file2': $!\n";&lt;BR /&gt;    while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;        @a = split /\n/;&lt;BR /&gt;        if ( exists  $frame{ $a[0] } ) {&lt;BR /&gt;            push( @{ $frame{ $a[0] } }, @a[ 1 .. $#a ] );&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;for my $key ( sort keys %frame ) {&lt;BR /&gt;    print join "\n", $key, @{ $frame{$key} }, "\n" if @{ $frame{$key} } &amp;gt; 0;&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./matchup file1 file2&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2009 19:18:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179387#M678493</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-04T19:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179388#M678494</link>
      <description>&lt;BR /&gt;We will call you Spanish file Spanish.txt and English file English.txt. The goal is to replace the n'th time stamp in the Spanish file with the n'th time stamp in the English file. Mel Burslan rightly pointed out that n'th instance of --&amp;gt; indicates the n'th time stamp. OK so far.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# Read Spanish File into a str variable.&lt;BR /&gt;var str Spanish ; cat "Spanish.txt" &amp;gt; $Spanish&lt;BR /&gt;# Read English file into a str variable.&lt;BR /&gt;var str English ; cat "English.txt" &amp;gt; $English&lt;BR /&gt;# Count the instances of --&amp;gt; in Spanish.&lt;BR /&gt;var int count ; set $count = { sen "--&amp;gt;" $Spanish }&lt;BR /&gt;# Replace one by one.&lt;BR /&gt;var int n ; set $n=1&lt;BR /&gt;while ($n &amp;lt;= $count)&lt;BR /&gt;do&lt;BR /&gt;    # Get the n'th time stamp from English.&lt;BR /&gt;    var str timestamp ; set $timestamp = { stex -p -r ("^\n&amp;amp;--&amp;gt;&amp;amp;\n^"+makestr(int($n))) $English }&lt;BR /&gt;    # Replance the n'th time stamp in Spanish with $timestamp (from English).&lt;BR /&gt;    sal -r ("^\n&amp;amp;--&amp;gt;&amp;amp;\n^"+makestr(int($n))) $timestamp $Spanish&lt;BR /&gt;done&lt;BR /&gt;# Write $Spanish back to file.&lt;BR /&gt;echo $Spanish &amp;gt; "Spanish.txt"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please test before using. I have not tested it. I have inserted comments, so you know what each line of the script is doing. Script is in biterscripting ( &lt;A href="http://www.biterscripting.com" target="_blank"&gt;http://www.biterscripting.com&lt;/A&gt; ) .&lt;BR /&gt;&lt;BR /&gt;Sen</description>
      <pubDate>Mon, 15 Jun 2009 14:30:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179388#M678494</guid>
      <dc:creator>Sen Hu</dc:creator>
      <dc:date>2009-06-15T14:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179389#M678495</link>
      <description>You can also use "cat -n".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Something like this might work, it's untested thou.&lt;BR /&gt;Usage: ./script.sh filename.txt grep-pattern&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;file=$1&lt;BR /&gt;grep=$2&lt;BR /&gt;tmp=$(cat -n $file | grep "$grep")&lt;BR /&gt;line=$(echo $tmp | awk '{print $1}'&lt;BR /&gt;total=$(wc -l $file)&lt;BR /&gt;tail=(($total - $line + 1))&lt;BR /&gt;head=10 # number of lines to show :)&lt;BR /&gt;&lt;BR /&gt;tail -n+$tail $file | head -n$head&lt;BR /&gt;&lt;BR /&gt;------&lt;BR /&gt;&lt;BR /&gt;As i said, it's untested.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Wed, 17 Jun 2009 10:33:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179389#M678495</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-06-17T10:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: search for number and extract lines below</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179390#M678496</link>
      <description>Thanks, will look into it</description>
      <pubDate>Fri, 06 Nov 2009 11:23:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-for-number-and-extract-lines-below/m-p/5179390#M678496</guid>
      <dc:creator>Gyankr</dc:creator>
      <dc:date>2009-11-06T11:23:48Z</dc:date>
    </item>
  </channel>
</rss>

