Search Results

Search: Posts Made By: Syeda Sumayya
Forum: Linux 11-02-2015
1,627
Posted By MadeInGermany
Or Ravinder's solution slightly changed awk...
Or Ravinder's solution slightly changed
awk 'FNR==NR{A[$1];next} ($1 in A){print $1,$2} ($2 in A){print $2,$1}' file1 file2
The order of the output is the one of file2.
Forum: Linux 11-02-2015
1,627
Posted By RudiC
Try awk ' FNR==NR {C[$1]++ ...
Try awk '
FNR==NR {C[$1]++
R[$1,C[$1]]=$2
C[$2]++
R[$2,C[$2]]=$1
next
}
$1 in C {for (i=1;...
Forum: Linux 10-29-2015
2,246
Posted By RavinderSingh13
Hello Syeda, Could you please try following...
Hello Syeda,

Could you please try following and let me know if this helps you.

awk '{A=$1}($1 != $2){A=$1 OFS $2} ($1 != $3){A=A?A OFS $3:$3} {print A;A=""}' Input_file
Output will be as...
Forum: Linux 10-28-2015
1,526
Posted By RavinderSingh13
Hello Syeda, Could you please try following...
Hello Syeda,

Could you please try following and let me know if this helps.

awk '{for(i=2;i<=NF;i++){sub(/\;/,X,$i);print $1 OFS $i}}' Input_file
Output will be as follows.

P38112 Q12389...
Forum: Linux 10-19-2015
1,753
Posted By MadeInGermany
With grep: grep -v 'refseq:NP.*refseq:NP' file ...
With grep:
grep -v 'refseq:NP.*refseq:NP' file
Not asked here, but I want to mention that sed can delete the nth occurrence, here the 2nd:
sed 's/|refseq:NP[_0-9]*//2' file

---------- Post...
Forum: Linux 10-19-2015
1,753
Posted By RudiC
Try alsoawk '2==gsub(/refseq:NP/,"&")' file ...
Try alsoawk '2==gsub(/refseq:NP/,"&")' file
DIP-23436N|refseq:NP_536784 DIP-23130N|refseq:NP_652017
DIP-22958N|refseq:NP_651195 DIP-20072N|refseq:NP_724597
DIP-22928N|refseq:NP_569972 ...
Forum: Linux 10-19-2015
1,753
Posted By RavinderSingh13
Hello Syeda, Could you please try following...
Hello Syeda,

Could you please try following and let me know if this helps.

awk '{count=gsub(/refseq:NP/,"refseq:NP",$0);if(count==NF){print}}' Input_file
Output will be as follows.
...
11,676
Posted By Don Cragun
Perhaps something more like: awk ' BEGIN...
Perhaps something more like:
awk '
BEGIN { printf(" ")
s = "sort"
}
FNR == 1 {
printf(" %s", files[++fc] = FILENAME)
}
{ d[$1, fc] = $2
c1[$1]
}
END { print ""
for(i in c1) {...
11,676
Posted By RavinderSingh13
Hello Syeda, For file1 and file2, could you...
Hello Syeda,

For file1 and file2, could you please try following and let me know if this helps.

awk 'BEGIN{print " file1 file2"}FNR==NR{;A[$1]=$NF;next} ($1 in A){print $1 OFS A[$1] OFS...
11,676
Posted By RavinderSingh13
Hello Syeda, Not sure which command you have...
Hello Syeda,

Not sure which command you have used, following and post#2 command provided be me works fine for me as follows.

awk 'BEGIN{print " file1 file2"}FNR==NR{;A[$1]=$NF;next} ($1 in...
2,146
Posted By RudiC
Different approach:awk '/^ *C/ {if (L) print...
Different approach:awk '/^ *C/ {if (L) print NR-L-1; printf "%s\t", $2; L=NR} END {print NR-L}' file
0001 5
0002 0
0003 0
0004 2
0005 2
2,146
Posted By MadeInGermany
The second solution more "verbose": awk ' ...
The second solution more "verbose":
awk '
function pr() {if (notfirst++) print heading,dcnt}
$1=="C" {pr(); heading=$2; dcnt=0}
$1=="D" {dcnt++}
END {pr()}
' file
2,146
Posted By Scrutinizer
Hi, try: awk '$1=="C"{i=$2; A[i]=0}...
Hi, try:
awk '$1=="C"{i=$2; A[i]=0} $1=="D"{A[i]++} END{for(i in A) print i,A[i]}' file

or

awk '$1=="C"{if(i!="") print i, c; i=$2; c=0} $1=="D"{c++} END{print i, c}' file
Forum: Linux 10-13-2015
2,076
Posted By RavinderSingh13
Hello Syeda, Here is an example suppose you...
Hello Syeda,

Here is an example suppose you want to substitute the 2nd occurrence of _ in $2 then following may help you.
Input_file:

Ravinder gi_49482297_ref_YP_039521.1_ TESTing test123...
Forum: Linux 10-13-2015
2,076
Posted By RavinderSingh13
Hello Syeda, If you want to only substitute...
Hello Syeda,

If you want to only substitute $2's _ present at last of $2then following may help you. As you had mentioned in first post that you need to substitute other columns _ too so I have...
Forum: Linux 10-13-2015
2,076
Posted By RavinderSingh13
Hello Syeda, Following may help you in same,...
Hello Syeda,

Following may help you in same, let's say you have a Input_file as follows(which is an example as you haven't shown us complete input and didn't tell us about field separator so I am...
Showing results 1 to 16 of 16

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