Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 01 Sep 2014, 07:32
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Bash: Count numbers in list
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 3 [33 Posts]   Goto page: Previous 1, 2, 3
Author Message
zigbert


Joined: 29 Mar 2006
Posts: 5697
Location: Valåmoen, Norway

PostPosted: Mon 27 Aug 2012, 16:32    Post subject:  

L18L wrote:
Why 3 columns?

Column 2 is not always basename.
Preferable it collects information from meta tags or m3u-file.

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5697
Location: Valåmoen, Norway

PostPosted: Mon 27 Aug 2012, 17:01    Post subject: Re: Awk: Count numbers in list  

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

Quote:
#!/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!!!!!

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 28 Aug 2012, 08:50    Post subject: Re: Awk: Count numbers in list  

zigbert wrote:
Else, I find this excellent!!!!!
And our thanks go to: jamesbond Exclamation
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 3 [33 Posts]   Goto page: Previous 1, 2, 3
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0514s ][ Queries: 11 (0.0047s) ][ GZIP on ]