Search Results

Search: Posts Made By: attila
3,026
Posted By Don Cragun
This is a little bit simpler than SriniShoo's...
This is a little bit simpler than SriniShoo's script and seems to do what was requested (but it doesn't print the trailing spaces that were included in the expected results shown in the 1st message...
3,026
Posted By SriniShoo
awk 'NR == 1{p=$4; print $0; next} {$4 = ($4 ==...
awk 'NR == 1{p=$4; print $0; next} {$4 = ($4 == "") ? p : $4}1' file
1,463
Posted By MadeInGermany
I suspect this is not always correct. I would...
I suspect this is not always correct.
I would prefer a simple
function min(a,b) {if (a<b) return a; return b}
and

Min[$8]=($8 in Min) ? min(Min[$8], min($9, $10)) : min($9, $10)

Dito with...
1,463
Posted By RudiC
Try sth along this line (and expand):awk ...
Try sth along this line (and expand):awk 'function min (M, V1, V2) {if ((!M) || V1<M) M=V1; if (V2<M) M=V2; return M}
function max (M, V1, V2) {if ((!M) || V1>M) M=V1; if (V2>M) M=V2;...
1,463
Posted By bartus11
Put this into "script.awk":BEGIN { ...
Put this into "script.awk":BEGIN {
a[9]=a[10]=a[12]=a[13]=a[15]=a[16]=a[18]=a[19]=1
}
NR==1 {
f=$1;n=$8;
for (i in a) {
m[i]=$i
M[i]=$i
}
}
{
for (i in a) {
...
3,570
Posted By RudiC
Trying to remember analytical geometry ... quite...
Trying to remember analytical geometry ... quite some time ago ... awk ' {X[NR]=$1; Y[NR]=$2}
NR==1 {next}
...
3,570
Posted By Akshay Hegde
Try Let me know if it's helpful for you ...
Try

Let me know if it's helpful for you

$ cat file
10 464310.16
20 464309.44
30 464309.02
40 464316.93
$ cat int.sh
#!/bin/bash

awk '
{
x[FNR]=$1
y[FNR]=$2...
1,543
Posted By pamu
try awk '{A[F]=$2>A[F]||!A[F]?$2:A[F]} $1...
try

awk '{A[F]=$2>A[F]||!A[F]?$2:A[F]}
$1 == 1 && NR > 1{if(A[F]){print 1,A[F]};F++}END{print 1,A[F]}' file
1,543
Posted By Yoda
If 2nd field is not sorted, using Jotne's idea: ...
If 2nd field is not sorted, using Jotne's idea:
awk 'NR > 1 && $1 == 1 { print $1, t; t = 0 } { t = t < $2 ? $2 : t }' file
1,543
Posted By Jotne
Like this? awk 'NR>1 && $1==1{print $1,t}...
Like this?
awk 'NR>1 && $1==1{print $1,t} {t=$2}'
1 4822
1 4882
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1 4801
1,543
Posted By mstafreshi
awk ' $2 > max { max = $2 } NR == 1 { next;...
awk '
$2 > max { max = $2 }
NR == 1 { next; }
$1 == 1 { print 1, max; max = $2; }
' filename
my code return one row less than your output! can it help you find your way ?
1,422
Posted By sathyaonnuix
# cat file A 0B 1828 C 100D 1666,C 200D...
# cat file
A 0B 1828
C 100D 1666,C 200D 1727,C 300D 1783,
A 0B 1786
C 200D 1727,C 100D 1666,C 300D 1783,
C 400D 1812,C 600D 1869,C 500D 1841,
C 400D 1812,C 500D 1841,C 600D...
1,383
Posted By Joseph_TKLee
awk '/^[A-Z]/ {print $0} /^[0-9]/ { for...
awk '/^[A-Z]/ {print $0} /^[0-9]/ { for (i=1;i<=NF;i=i+2) print $i,$(i+1) }' input.txt


Cheers,
1,383
Posted By rdcwayx
awk '/HANDVEL/{print;next}{for (i=1;i<=NF;i=i+2)...
awk '/HANDVEL/{print;next}{for (i=1;i<=NF;i=i+2) print $i,$(i+1)}' infile
1,619
Posted By pamu
Try awk '$1=="CE2_12-15"{$2=(4086-$2)*2} ...
Try

awk '$1=="CE2_12-15"{$2=(4086-$2)*2}
$1=="CE2_12-52"{$2=($2-836)*2}
$1=="CE2_12-54"{$2=($2-1088)*2}1' file
1,320
Posted By guruprasadpr
Hi Altering the first part of the command:...
Hi

Altering the first part of the command:

$ awk '/=X/{if(x)print x;x="";}{if(x)x=x"#"$0;else x=$0;}END{print x}' file | awk '$0 !~ /^ROUTE/{print x, $0;next}{x=$0;}' | sort -t"(" -k2n,2 | \...
990
Posted By guruprasadpr
Hi $ awk -F '[RG ]' '{print $2$3" =...
Hi


$ awk -F '[RG ]' '{print $2$3" = G,";}' file
103150111 = G,
103150121 = G,
103150131 = G,
103150141 = G,
103150151 = G,

Guru.
990
Posted By balajesuri
sed 's/[^0-9]*\([0-9]*\) \([0-9]*\)\(.\).*/\1\2 =...
sed 's/[^0-9]*\([0-9]*\) \([0-9]*\)\(.\).*/\1\2 = \3,/' input.txt
1,582
Posted By Chubler_XL
How about: awk 'p { print ($1+p)/2} p=$1'...
How about:
awk 'p { print ($1+p)/2} p=$1' input.txt
14,661
Posted By agama
Try this: awk 'NR % 3 == 0' input-file...
Try this:

awk 'NR % 3 == 0' input-file >output-file


Should print as you want.
1,911
Posted By ygemici
# awk '{a[x++]=$0;b[$1]++} function...
# awk '{a[x++]=$0;b[$1]++}
function calrnum(ar,i){
$R=ar[i];f=gensub(".*\\.","\\1","R")
if(f>=5){ar[i]+=1};if(i%2!=1){printf " %4d%s",ar[i],"B";}else{printf " %4d%s",ar[i],",A";}}
function...
1,911
Posted By Skrynesaver
Skrynesaver@busybox ~$ perl -Mstrict -e ' sub...
Skrynesaver@busybox ~$ perl -Mstrict -e '
sub round{
my $num=shift;
return int($num + 0.5);
}
my $rec_id=undef;

while(<>){
my ($A,$B,$dat)=split(/\s+/,$_);
if($A != $rec_id){
...
1,729
Posted By itkamaraj
Nice code guru. But it needs a small...
Nice code guru.

But it needs a small correction
1,729
Posted By guruprasadpr
Hi $ awk 'x!=$1{print "LINE...
Hi


$ awk 'x!=$1{print "LINE ",$1,",";x=$1}{ print $2," = ",$2," ,";}' file1

Guru.
5,716
Posted By itkamaraj
$ nawk -F\| '$1~/ 1 / && $4~/[0-9]/ && $2~/DISK/'...
$ nawk -F\| '$1~/ 1 / && $4~/[0-9]/ && $2~/DISK/' *
$$ 1 | DISK | TR1311 | 1 |$$
$$ 1 | DISK | TR1312 | 1 |$$
$$ 1 | DISK | TR1317 | 1 |$$
$$ 1 | DISK | TR1313 | 1 |$$
$$ 1 | DISK | TR1319 | 1...
Showing results 1 to 25 of 27

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