Search Results

Search: Posts Made By: jiam912
3,207
Posted By nezabudka
I understand your idea. You have a list sorted by...
I understand your idea. You have a list sorted by ID and you process one ID at a time. You assume that the file being processed is too large for the memory allocated for this. I want to note the...
3,207
Posted By nezabudka
Slight optimization awk ' !A9[$1]++ ...
Slight optimization
awk '
!A9[$1]++ {A2[$1]=$3;A4[$1]=$5;A6[$1]=$6}
A2[$1]>$3 {A2[$1]=$3}
A3[$1]<$3 {A3[$1]=$3}
A4[$1]>$5 {A4[$1]=$5}
A5[$1]<$5 {A5[$1]=$5}...
6,456
Posted By nezabudka
Hi GNU extension includes a multiline modifier...
Hi
GNU extension includes a multiline modifier M,m
sed -rz 's/(a.*\n)\n+(c.*)/\1\2/m'

--- Post updated at 06:36 ---

the wolves be sated and the sheep intact
sed -r...
6,456
Posted By RudiC
Not that easy as your start pattern occurs...
Not that easy as your start pattern occurs multiple times. For your sample, adapting your first attempt:
tac file | sed '/ccc/,/aaa/{/^ *$/d;}' | tac
aaa 409
bbb 201

122 0.98
aaa 1.47
aaa...
2,888
Posted By RudiC
What if a value falls into the gap between e.g. 0...
What if a value falls into the gap between e.g. 0 and 0.01? This is not covered here. Make sure none of your values fall into those gaps. Try this
$ awk -v"MIN=0" -v"MAX=20" '
BEGIN {delta =...
2,888
Posted By RudiC
Just run the for loop up to MXBCK in lieu of...
Just run the for loop up to MXBCK in lieu of numBuckets (whose final value you ignore, BTW, running the loop with < instead of <=)


Where did your request for a MIN value disappear that you...
2,888
Posted By Neo
Hi, What does this word mean (you used it many...
Hi, What does this word mean (you used it many times):



What do you mean by this word, exactly?

Do you mean "columns" (in an ASCII table)?

Thanks.
Forum: What is on Your Mind? 02-19-2020
7,338
Posted By Neo
FYI: Stack Overflow... seems there's quite a revolt of sorts going on over there and everywhere.
I realize all online communities go though some rough times every now and then; but I did not realize things had gone so far "south" at Stack until a friend forwarded me this today.



I have no...
2,511
Posted By RudiC
I think your small request more can easily be...
I think your small request more can easily be satisfied along the lines shown by rdrtx1 and me...
2,511
Posted By vgersh99
RudiC/rdrtx1, the binning, the percentage and...
RudiC/rdrtx1,
the binning, the percentage and the totals are somewhat different from the OP's desired output in post #1.
Hence post #2 with the ask to elaborate.
2,511
Posted By rdrtx1
same as above but total included: awk 'BEGIN {...
same as above but total included:
awk 'BEGIN { delta = (delta == "" ? 2 : delta) ; max=20 }
{
if ($1 > max) {
maxf++;
maxc+=$2;
} else {
bucketNr = int(($1+delta) / delta)
cnt++...
2,511
Posted By RudiC
For your "max bin" question, try awk...
For your "max bin" question, try

awk -v"MAX=20" '
BEGIN {delta = (delta=="")?2:delta
MXBCK = (MAX / delta) + 1
}

{bucketNr = int(($1+delta) / delta)
if...
2,511
Posted By RudiC
How far would this small adaption to your code...
How far would this small adaption to your code get you:
awk '
BEGIN {delta = (delta=="")?2:delta
}

{bucketNr = int(($1+delta) / delta)
cnt[bucketNr] += $2
...
4,007
Posted By RudiC
Are you able to live with "0.00 0.00" in a pair's...
Are you able to live with "0.00 0.00" in a pair's first line? Try
awk '
{printf "%s" OFS, $0
}
!X[$1,$2] {print "0.00", "0.00"
}
X[$1,$2]++...
4,007
Posted By rdrtx1
awk '{ line[NR]=$0; pp[NR] = $2 ll[NR] = $1...
awk '{
line[NR]=$0;
pp[NR] = $2
ll[NR] = $1
x[NR] = $4
y[NR] = $5
z[NR] = $6
rc[$1,$2]++
} END {
first = 1
count = 0
for ( i=1 ; i <= NR ; i++ ) {
if (pp[i] == pp[i+1] && ll[i] ==...
Forum: What is on Your Mind? 01-24-2020
9,667
Posted By Neo
Moderators of the Year 2019 - Ravinder Singh and Victor Berridge
Today, I am very pleased to announce that the Moderator of the Year Award, 2019 has two very deserving winners.

Ravinder Singh (RavinderSingh13) and Victor Berridge (vbe)

Victor (vbe) has...
1,946
Posted By RudiC
On top of what RavinderSingh13 already said,...
On top of what RavinderSingh13 already said, similar problems have been solved umpteen times in these fora. Try to find (and adapt?) one or several...
1,946
Posted By RavinderSingh13
Hello jiam912, We encourage users to add...
Hello jiam912,

We encourage users to add their efforts which they have put in order to solve their own problems in their post.
So kindly do let us know what you have tried to solve this?
...
4,479
Posted By nezabudka
awk ' !($2 in t) {nl = NR; printf max $2...
awk '
!($2 in t) {nl = NR; printf max $2 FS $3 FS}
{t[$2]++; max = $3 FS t[$2] FS nl FS NR RS}
END {printf max}
' file
4,479
Posted By rdrtx1
awk ' { if (!col2[$2]++) cols[c++]=$2; ...
awk '
{
if (!col2[$2]++) cols[c++]=$2;
if (!length(min[$2]) || $3 < min[$2]) min[$2]=$3;
if (!length(max[$2]) || $3 > max[$2]) max[$2]=$3;
}
END {
for (i=0; i<c; i++) {
...
4,479
Posted By anbu23
$ awk '{ currKey = $2 } > currKey != prevKey {...
$ awk '{ currKey = $2 }
> currKey != prevKey { prt(); min=$3; cnt=0 }
> { prevRec=$0; prevKey=currKey; max=$3; cnt++ }
> END { prt() }
>
> function prt( f) {
> if ( cnt ) {
> ...
2,942
Posted By vgersh99
Take the latest code - I had to change something...
Take the latest code - I had to change something to split the first field.
You don't need to make the change you mentioned above....
2,942
Posted By vgersh99
how about: FNR==NR { f1_56[$3$4]=($5 OFS $6)...
how about:

FNR==NR { f1_56[$3$4]=($5 OFS $6)
f1_78[$3$4]=($7 OFS $8)
next
}
{$(NF+1)="O"}
!($1 in f1_56) { $1=substr($1,1,5) OFS substr($1,6)}
$1 in f1_56 {
...
2,942
Posted By steveo314
are you required to use awk or could you write a...
are you required to use awk or could you write a perl script?
1,750
Posted By Don Cragun
Hi jiam912, I think Ravinder has accurately...
Hi jiam912,
I think Ravinder has accurately described how each line in my script works. The slightly higher level overview is that the first loop gathers data from each line in your file as it is...
Showing results 1 to 25 of 317

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