Search Results

Search: Posts Made By: jontjioe
2,041
Posted By ahamed101
awk '{gsub(/\\|\$/,"#");if($2 in...
awk '{gsub(/\\|\$/,"#");if($2 in a){}else{a[$2]=i++;}gsub($2,a[$2])}1' infile

53600.88 0 129048320 16 0
53601.96 0 100679424 8 0
53602.16 1 14080 1 0
53603.97 2 95010560 128 0
53614.06 0...
2,041
Posted By shamrock
awk '{x[$0]++}END{for(i in x) print i,x[i]}'...
awk '{x[$0]++}END{for(i in x) print i,x[i]}' array.txt
2,041
Posted By ahamed101
sort yourfile | uniq Is this what you...
sort yourfile | uniq


Is this what you want?

--ahamed
3,761
Posted By pravin27
Try this, sort -nk2 -nk1 testfile.txt | awk...
Try this,
sort -nk2 -nk1 testfile.txt | awk '{if($2 in a){diff=diff+$1-a[$2];a[$2]=$1;i++;b=$2;next}
else {
if(i>0) {--i;if(i==0){printf "%s %f\n",b,0}else{printf "%s %f\n",b,diff/i;}}...
6,336
Posted By DGPickett
Well, it sounds like you should not try to do too...
Well, it sounds like you should not try to do too much at once! You have a sector start and length, so convert to sector range first last, and then to page range first last, and then iterate the...
4,534
Posted By cgkmal
Hi jontjioe, Another with awk: awk...
Hi jontjioe,

Another with awk:
awk '{nr=NR%2?(NR-1)/2+1:NR/2;a[NR]=$1}END{print a[nr]}' file1

Regards.
4,534
Posted By tene
Try this. awk '{arr[NR]=$1}...
Try this.

awk '{arr[NR]=$1} END{if(NR%2==0)print arr[NR/2]; else print arr[(NR-1)/2]}' inputfile
4,534
Posted By Chubler_XL
Yes the awk script requires the same file to be...
Yes the awk script requires the same file to be passed into it twice, first pass it to get total records 2nd prints the line.

Shame both your demo files produce the same output:
$ awk...
4,534
Posted By kurumi
Ruby(1.9+) $ ruby -0777 -ne...
Ruby(1.9+)

$ ruby -0777 -ne 's=$_.split("\n"); puts (s.size%2==0)? s[(s.size/2)-1]:s[s.size/2] ' file
1,935
Posted By yinyuemi
try: awk '{a[$2]}$NF=="0"{++b[$2]}END{for(i in...
try:
awk '{a[$2]}$NF=="0"{++b[$2]}END{for(i in a) print i,b[i]?b[i]:"0"|"sort -n"}' file
3,417
Posted By Franklin52
Try: awk 'NR==FNR{a[$1]++;next} {$1=a[$1]?$1...
Try:
awk 'NR==FNR{a[$1]++;next}
{$1=a[$1]?$1 FS a[$1]:$1 FS "0"}
1' filename2 filename1 > newfile
3,974
Posted By Scrutinizer
Or shell: while read fdate rest; do echo...
Or shell:
while read fdate rest; do
echo $(date -j -f "%d/%b/%Y:%T" $fdate +%s) "$rest"
done < myfile
3,974
Posted By radoulov
You need a bit more code to make it work with awk...
You need a bit more code to make it work with awk :).

Anyway, I would use Perl:

perl -MTime::Local -lane'BEGIN {
$month{$_} = ++ $c
for "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC" =~ /.../g...
1,959
Posted By guruprasadpr
Hi awk 'NR==FNR{a[$2]=$1;next;}{if ($3 in a)...
Hi

awk 'NR==FNR{a[$2]=$1;next;}{if ($3 in a) print a[$3], $0;}' file1 file2


Guru.
Showing results 1 to 14 of 14

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