Search Results

Search: Posts Made By: AshwaniSharma09
1,926
Posted By MadeInGermany
Thanks for the correction. And there is yet...
Thanks for the correction. And there is yet another bug.
Hopefully fixed now:
sort Input.txt | uniq -c | sort -k2,2 -k1,1rn | awk '{ if ($2!=p2 || $1==p1) {print $2,$3,$1; p1=$1} else {p1=""}}...
1,926
Posted By Don Cragun
A single awk command could do this more...
A single awk command could do this more efficiently, but I find the logic easier to express with a couple of sort commands, one uniq command, and a read loop in the shell...
#!/bin/ksh
last_gene=""...
1,926
Posted By Scrutinizer
Hi, another one to get you started: The...
Hi, another one to get you started:

The code needs to modified still to print the highest number of connections rather than only the number of connections...

awk's associative arrays are nice...
1,926
Posted By sea
What have you tried so far? ---------- Post...
What have you tried so far?

---------- Post updated at 05:24 ---------- Previous update was at 04:06 ----------

Funny, i just looked at the output (ignoring the BP8 as i see now - sorry), and...
4,450
Posted By RudiC
This post...
This post (https://www.unix.com/302738343-post7.html) results (after adapting the output format) in CPLX9PC-4943 CpxID123 CpxID126 CPLX9PC-5763 CpxID13 CPLX9PC-6163...
4,450
Posted By pamu
Or.. $ awk...
Or..

$ awk '{A[$1,$2]=$3;B[$1]++;C[$2]++}END{for(i in C){s=s?s"\t"i:"\t"i}
print s;
for(i in B){s=i;
for(j in C){s=s"\t"A[j,i]}
print s}}' file

a b c
a 1 2 ...
4,450
Posted By Don Cragun
If you don't have GNU R and want a table that...
If you don't have GNU R and want a table that adjusts to the input given, you could try something like:
awk '
NF == 3 {
if(!($1 in rh)) {
# Add a new row heading.
...
4,450
Posted By mirni
Try this: awk ' {a[$1,$2]=$3; b[$1];} END{ ...
Try this:
awk '
{a[$1,$2]=$3; b[$1];}
END{
for(i in b) #print header
printf("\t%s",i);
printf("\n");
for(i in b) { #each row
printf("%s\t",i);
for(j in b) #each...
3,363
Posted By pravin27
How about this ? #!/usr/bin/perl use...
How about this ?

#!/usr/bin/perl
use strict;
my $file1=shift;
my $file2=shift;
my %seen;
open (FH,"$file1") or die "can not open file $file1 - $! \n";
while (<FH>) {
chomp;
...
3,363
Posted By RudiC
For your first request, you might want to give...
For your first request, you might want to give this a shot:awk 'NR==1 {Pat = "["}
NR==FNR {Pat = Pat $1;next}
FNR==1 {Pat=Pat"]"}
{for (i=1;...
3,363
Posted By Yoda
awk ' BEGIN { c = 1 } FNR == NR { ...
awk ' BEGIN {
c = 1
} FNR == NR {
A[$0] = $0
next
} {
M_F = "C" c "match.txt"
N_F = "C" c "non_match.txt"

for ( j = 1; j <= NF; j++ )
...
1,966
Posted By Scrutinizer
Perhaps there are tabs present in the input file?...
Perhaps there are tabs present in the input file?
awk -F'[, \t]' ...
1,966
Posted By user8
This works for me (using gawk): gawk -F',| '...
This works for me (using gawk):
gawk -F',| ' '!(a[$1,$2]++ + a[$2,$1]++)'
1,966
Posted By Don Cragun
Try: awk '{ split($1, f, /,/) ...
Try:
awk '{ split($1, f, /,/)
if((f[2]","f[1]) in o) next
o[$1]
print
}' input
As always, if you are using a Solaris/SunOS system, use /usr/xpg4/bin/awk or nawk instead...
5,698
Posted By Corona688
Whenever you have sed | awk | grep | kitchen |...
Whenever you have sed | awk | grep | kitchen | sink, it can probably be done all in one awk. It's a lot more than a glorified 'cut'.

1) Search for a line containing CYTOCHROME C where there's two...
5,698
Posted By Vryali
I'm not sure about everything you want to do, but...
I'm not sure about everything you want to do, but I think this does most of it:

sed -n '/^[\ \t]*COMPND.*CYTOCHROME\ C.*/{n;p;}' out.test | awk -F":" '{print $2}' | sed 's/[\ \,]//g'

sed -...
3,462
Posted By rdcwayx
awk 'NR==FNR{a[$1]=$2;next}{print $1,a[$1]}'...
awk 'NR==FNR{a[$1]=$2;next}{print $1,a[$1]}' small_file.txt huge_file.txt
3,462
Posted By ranjithpr
Hope this is what you were expecting
$ cat huge_file.txt
a
a
ab
b
hh
$ cat small_file.txt
a 1.5
b 2.5
ab 7.5
cd 1.1
$ awk 'NR==FNR{buff[$1]=$0;next} {if(buff[$1]!="") print buff[$1]}' small_file.txt huge_file.txt
a 1.5
a...
Showing results 1 to 18 of 18

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