Search Results

Search: Posts Made By: polsum
1,577
Posted By CarloM
awk 'NR==FNR{a[$1]=$2;next}{for (i in a)...
awk 'NR==FNR{a[$1]=$2;next}{for (i in a) gsub(i,a[i]); print }' file1 file2
1,577
Posted By bartus11
Try:awk...
Try:awk 'NR==FNR{a[$1]=$2;next}!(FNR%3){n=split($0,x,"");$0="";for (i=1;i<=n;i++)$0=$0""a[x[i]]}1' file1 file2
1,836
Posted By bartus11
Try this website: The AWK Manual - Table of...
Try this website: The AWK Manual - Table of Contents (http://www.staff.science.uu.nl/~oostr102/docs/nawk/nawk_toc.html)
1,836
Posted By bartus11
Try: awk 'NR==FNR{for (i=3;i<=NF;i++)...
Try: awk 'NR==FNR{for (i=3;i<=NF;i++) a[$1"-"i]+=$i;next}FNR>1{for (i=3;i<=NF;i++) $i=sprintf ("%.2f",($i*100)/a[$1"-"i])}1' file file
Notice that you have to specify filename twice.
1,890
Posted By Scrutinizer
Try: awk 'NR==1 || $2==$3 && $3==$4 && $5==$6...
Try:
awk 'NR==1 || $2==$3 && $3==$4 && $5==$6 && $6==$7' infile
-or less robust-
sed -n '1p;/[^ ]*\( [^ ]*\)\1\1\( [^ ]*\)\2\2/p' infile
2,384
Posted By bartus11
Try: awk '$2>M[$5]{M[$5]=$2;a[$5]=$0}END{for (i...
Try: awk '$2>M[$5]{M[$5]=$2;a[$5]=$0}END{for (i in a) print a[i]}' file
2,837
Posted By Franklin52
awk 'NR==FNR{a[$1]=1;next} a[$5]{if($2 >...
awk 'NR==FNR{a[$1]=1;next} a[$5]{if($2 > a[$5]){a[$5]=$2;b[$5]=$0}} END{for(i in b)print b[i]}' file1 file2
2,837
Posted By Franklin52
Try this: awk 'NR==FNR{a[$1]=1;next}($1 in a)...
Try this:
awk 'NR==FNR{a[$1]=1;next}($1 in a) && $2 > a[$1]{a[$1]=$2}END{for(i in a)print i, a[i]}' file1 file2
2,245
Posted By Corona688
another way using awk: awk '/SQ/ { P=1;...
another way using awk:

awk '/SQ/ { P=1; print }; /\/\// { P=0; print }; !P' filename
2,245
Posted By birei
Hi polsum, Try (using flip-flop in perl): ...
Hi polsum,

Try (using flip-flop in perl):

$ perl -wlne 'if ( $c = (m|SQ|..m|//|) ) { next unless $c == 1 || $c =~ m/E0$/ } print' infile
SQ kkk m99029 wwwAV
//
AS
DS
SQ ooo l9909 qqqqa
//...
4,692
Posted By uniqme
cat f1.txt a 455 b 443 c 6655 d 554 ...
cat f1.txt

a 455
b 443
c 6655
d 554
e 6

$ cat f2.txt

a 56
b 5
x 678

awk '$0 !~ /#/{arr[$1]=arr[$1] " " $2}END{for(i in arr)print i,arr[i]}' f1.txt f2.txt

x 678
a 455 56
b ...
4,692
Posted By yinyuemi
if you have multiple files,please try this:awk...
if you have multiple files,please try this:awk '{a[ARGIND" "$1]=$2;b[$1];t=ARGIND}END{for(i in b){printf i ;for(j=1;j<=t;j++)printf FS (length(a[j" "i])?a[j" "i]:"0");print ""}}' file1 file2 file1...
4,692
Posted By yinyuemi
awk '{if($1 in a){sub("0"...
awk '{if($1 in a){sub("0" FS,"",a[$1]);a[$1]=a[$1] FS $2}else{a[$1]="0" FS $2}}END{for(i in a)print i,a[i]}' file1 file2
2,544
Posted By ahamed101
There are so many posts in this forum with the...
There are so many posts in this forum with the same query...

awk 'NR==FNR{_[$3]++;next}!_[$3]' file2 file1
--ahamed
7,220
Posted By yazu
Assuming you don't want lines when the first...
Assuming you don't want lines when the first field repeats N times:
awk -v N=10 '
$1 != prev {
if (c != N) for (i=1; i<=c; i++) print a[i]
c = 0
}
{
a[++c] = $0;
prev = $1;
} ...
7,220
Posted By birei
Hi polsum, Here you have another 'perl'...
Hi polsum,

Here you have another 'perl' solution:

$ cat File1
13 18 1 + chromosome 1, 122638287 AGAGTATGGTCGCGGTTG
13 18 1 + chromosome 1, 128904080 AGAGTATGGTCGCGGTTG
13 18 1 - chromosome...
7,220
Posted By rangarasan
PERL
Hi,

Try this code,


#! /usr/local/bin/perl
open(FILE,"<File1") or die("unable to open file");
my @mContent = <FILE>;
my %mFinal = ();
foreach ( @mContent )
{
my $mLine = $_;
...
2,247
Posted By durden_tyler
$ $ $ cat data.txt 2 7 18 ggcgt anna 2 9...
$
$
$ cat data.txt
2 7 18 ggcgt anna
2 9 24 kosss Brenham
4 7 18 hhcjd jenny
3 8 21 kkok bush
2 7 18 hhchc sam
0 8 21 jjdhs sam
3 7 18 hhdjcc ross
$
$
$ perl -lne 'push @x, $_;
...
1,509
Posted By bartus11
#!/usr/bin/perl open A, "$ARGV[1]"; open B,...
#!/usr/bin/perl
open A, "$ARGV[1]";
open B, "$ARGV[0]";
chomp(@x=<A>);
local $/;
$_=<B>;
for $x (@x){
s/$x.*//g;
}
print;
Run it like this: ./script.pl file1 file2
4,159
Posted By g.pi
@polsun, let me make a suggestion, if I may. ...
@polsun, let me make a suggestion, if I may. Since you are learning something new, I suggest that you learn perl instead. Perl can pretty much do what awk can (IMHO) and lots more. It is not...
1,461
Posted By bartus11
Try: perl -p0e...
Try: perl -p0e 's/^(\w)(.*)(\w+)\n\1.*?(\w+)$/\1\2\3_\4/mg' file
4,552
Posted By alister
If you prefer it that way, sure. awk -f...
If you prefer it that way, sure.

awk -f dna.awk f2='file2' file1Where dna.awk contains:
{chr=$6; min=$7; max=$8; s=$11" "$12" "$13; getline < f2; if (chr==$4 && $5>=min && $5<=max) print $0,...
4,552
Posted By alister
Here's a simpler approach that only uses AWK (and...
Here's a simpler approach that only uses AWK (and which I should've suggested from the beginning):
awk '{chr=$6; min=$7; max=$8; s=$11" "$12" "$13; getline < f2; if (chr==$4 && $5>=min && $5<=max)...
4,552
Posted By alister
What do you mean you should not type "paste"? Or...
What do you mean you should not type "paste"? Or that you should not use \\n? "paste" is the name of the command. You must type it. "\\n" is an option argument to paste that tells it to use a...
4,552
Posted By curleb
Neglected is more accurate. Intrigued by that use...
Neglected is more accurate. Intrigued by that use of paste. Sorry.
Showing results 1 to 25 of 34

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