Page 2 of 2

Posted: Mon 27 Aug 2012, 20:32
by zigbert
L18L wrote:Why 3 columns?
Column 2 is not always basename.
Preferable it collects information from meta tags or m3u-file.

Re: Awk: Count numbers in list

Posted: Mon 27 Aug 2012, 21:01
by zigbert
L18L wrote:
zigbert wrote:Also, what we want is to define a alternative max value to find timestamps in a specific period. - Like february 2012. Let's say that is $4.
Where is $1 ? $1 is for pMusic internal redirection

Here is a solution using $1 and $2 timestamp from and -to
#!/bin/ash
#additional output filename only=basename
#TIMESTAMP from to
#
LANG=C
#
FIND_FROM=$1 #timestamp
FIND_TO=$2

awk -F, -v TS1=$FIND_FROM -v TS2=$FIND_TO '{
split($1, a, "|"); $1=a[2] # fix first entry

max=NF; min=0;
while (max-min > 1) {
i=int( (max+min)/2 )
if (TS1 >= $i) min = i
else max = i
}
from=NF-min

max=NF; min=0;
while (max-min > 1) {
i=int( (max+min)/2 )
if (TS2 >= $i) min = i
else max = i
}
to=NF-min

variable 'to' is never 0, even if zero hits

num=split (a[1], b , "/")
print a[1], b[num], from-to

}' database.txt
Else, I find this excellent!!!!!

Re: Awk: Count numbers in list

Posted: Tue 28 Aug 2012, 12:50
by L18L
zigbert wrote:Else, I find this excellent!!!!!
And our thanks go to: jamesbond :!: