Search Results

Search: Posts Made By: acsg
4,696
Posted By yazu
Change to: for $time (@ts) { ...
Change to:
for $time (@ts) {
$nt += $time - $prev;
$prev = $time;
}
4,696
Posted By yazu
Just change to push @{$seen{"@F[3..16]"}},...
Just change to
push @{$seen{"@F[3..16]"}}, $F[0];
It changes spaces to one. If you want to save them you need use substr() on $_. If you want another output separator then change it in END block...
4,419
Posted By Scrutinizer
Hi, here is a clarification: {B[$1]}|Create...
Hi, here is a clarification:

{B[$1]}|Create an array element B[$1] . If such an element already exists then this will not create a new element, hence an element will only be created once for the...
4,419
Posted By Scrutinizer
Like this? awk '{B[$1]} !(NR%7){for(i in...
Like this?
awk '{B[$1]} !(NR%7){for(i in B){delete B[i];A[i]++}} END{for(i in A)print i,A[i]}' infile
4,419
Posted By bartus11
Try: perl -lane...
Try: perl -lane '$x=int(($.-1)/7);$a{$x}{$F[0]}=1;END{for $i (keys %a){for $j (keys %{$a{$i}}){$b{$j}++}};for $i (keys %b){print "$i $b{$i}"}}' file
13,703
Posted By Franklin52
Try this one: awk '{a[++c]=$1;...
Try this one:
awk '{a[++c]=$1; b[c]=b[c-1]+$2;t+=$2}END{for(i=1;i<=c;i++)print a[i],b[i]/t}' file
13,703
Posted By Franklin52
... | sort | awk '{a[++c]=$1;...
... | sort |
awk '{a[++c]=$1; b[c]=$2}END{for(i=1;i<=c;i++)print a[i], b[i]/b[c]}'

Edit: should be:

... | sort |
awk '{a[++c]=$1; b[c]+=$2}END{for(i=1;i<=c;i++)print a[i], b[i]/b[c]}'
2,814
Posted By |UVI|
cat input.txt | awk 'BEGIN{ while (getline ...
cat input.txt | awk 'BEGIN{
while (getline > 0 && NF > 0){
data_array[$1]+=0
if ( NR > 1 ){
C1 = $1
C2 = $2

if ( P1 == C1 && P2 != C2){
...
3,040
Posted By cgkmal
Hi acsg, You can use sort command: sort...
Hi acsg,

You can use sort command:
sort -k1,1n -s inputfile
160 1
160 2
160 3
161 2
161 3
161 4
161 6
162 2
162 3
162 1

See "man sort" and you'll get that:
-k=Option to set the key...
2,814
Posted By mirni
<--- That was missing. Test this out: awk '...
<--- That was missing. Test this out:

awk '
ch!=$1{ch=$1;seq=$2} #initialize with new channel
ch==$1{ #channel same as stored
if(seq==$2) next; #if same, skip to next...
2,814
Posted By |UVI|
cat input.txt | awk 'BEGIN{ while (getline ...
cat input.txt | awk 'BEGIN{
while (getline > 0){
if ( NR > 1 ){
C1 = $1
C2 = $2

if ( P1 == C1 && P2 != C2){
if ( (P2+1)%16 != C2 )
...
2,814
Posted By |UVI|
another way awk 'BEGIN{ while (getline ...
another way

awk 'BEGIN{
while (getline > 0){
if ( NR > 1 ){
C1 = $1
C2 = $2

if ( P1 == C1 ){
if ( (P2+1)%16 != C2)
data_array[$1]++
}
...
2,814
Posted By mirni
How about this... awk ' ...
How about this...
awk '
ch!=$1{ch=$1;seq=$2} #initialize with new channel
ch==$1{ #channel same as stored
if((seq++%16)!=$2) #increment and cycle the counter; compare
...
3,040
Posted By cgkmal
acsg, Try with: awk '{for(i=4;i<=NF;i=i+2)...
acsg,

Try with:
awk '{for(i=4;i<=NF;i=i+2) print $i,$(i+1)}' inputfile

Hope this helps.

Regards
Showing results 1 to 14 of 14

 
All times are GMT -4. The time now is 09:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy