Search Results

Search: Posts Made By: nengcheng
6,407
Posted By RudiC
Try awk 'LAST != $1 {printf "%s%s", DL, $0;...
Try
awk 'LAST != $1 {printf "%s%s", DL, $0; LAST = $1; DL = RS; next}; {printf "\t%s", $2} END {printf RS}' file
A value1 value2 value3
B value1 value2 value3
C value1 ...
3,523
Posted By nezabudka
sed 's/^\(.\),/\1&/'
sed 's/^\(.\),/\1&/'
3,523
Posted By RavinderSingh13
Hello nengcheng, It is always recommended to...
Hello nengcheng,

It is always recommended to add your efforts in your post which you have out in order to solve your own problem, could you please try following.


awk 'BEGIN{FS=OFS=","}...
1,582
Posted By MadeInGermany
A posix awk (including mawk and and some nawk)...
A posix awk (including mawk and and some nawk) regognizes "inf" as a valid number (infinity).
awk '{printf "%.3f\n", $1}' fileGNU awk needs --posix
awk --posix '{printf "%.3f\n", $1}' file
1,582
Posted By Yoda
sprintf is an awk string function. For further...
sprintf is an awk string function. For further reference check: String Functions
(https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html)sprintf(format, expression1, …)
Return...
1,582
Posted By RudiC
How about awk '!/[^0-9-.]/ {$1 = $1+0} {print...
How about
awk '!/[^0-9-.]/ {$1 = $1+0} {print "" $1} ' CONVFMT="%.3f" file
inf
1.241
-0.186
-0.349
inf
0.127
0.240
-0.120
1,582
Posted By RavinderSingh13
Hello nengcheng, Following awk may also help...
Hello nengcheng,

Following awk may also help you in same.


awk '$0 !~ /[a-zA-Z]+/{printf("%.03f\n",$0);next} 1' Input_file


Thanks,
R. Singh
1,582
Posted By Yoda
Try using character class...
Try using character class (https://www.gnu.org/software/gawk/manual/html_node/Bracket-Expressions.html) [:alnum:] - Alphanumeric characters:-
awk '!/[:alnum:]/{$1=sprintf("%.3f",$1)}1' file
3,607
Posted By durden_tyler
$ $ cat list_comb.txt a b c d E F G H $ ...
$
$ cat list_comb.txt
a b c d
E F G H
$
$ perl -lne 'sub comb {return if !$#_;
print for glob join "", map "{$_}", map {join ",", @$_}([shift],\@_);
...
3,607
Posted By Aia
Run as python combination.py nengcheng.file ...
Run as python combination.py nengcheng.file

import fileinput
import itertools

for line in fileinput.input():
fields = line.split()
for L in range(2, len(fields)-1):
for...
3,607
Posted By RudiC
My python is non-existent, but I guess what you...
My python is non-existent, but I guess what you post just uses an array of constants and doesn't read and loop your input file.
And, I don't think Don Cragun was talking of copying google results...
3,607
Posted By Don Cragun
Instead of just saying you're a beginner, why...
Instead of just saying you're a beginner, why don't you put a little effort into this and try to solve it on your own. If you get stuck, show us what you have tried and explain where you got stuck.
1,239
Posted By Don Cragun
That will work with some versions of awk and give...
That will work with some versions of awk and give you a syntax error with other versions of awk. The following should work with almost any version of awk:
awk '{$1=$1; print>("file"NF)}'...
1,239
Posted By durden_tyler
$ $ cat dataset_1.txt A B C D A C C...
$
$ cat dataset_1.txt
A B C D
A C
C D E
F G H
F D K
Y
X A
K K C G
$
$ awk '{$1=$1; print>"file"NF}' dataset_1.txt
$
$ cat file1
Y
$
$ cat file2
A C
X A
$
1,055
Posted By Scrutinizer
Hi, try: awk 'NR==FNR{A[$1]; next} $1 in A &&...
Hi, try:
awk 'NR==FNR{A[$1]; next} $1 in A && $2 in A' file1 file2
1,075
Posted By Scrutinizer
Hi, try: awk 'NR==FNR{A[$1,$2]; next} !(($2,$1)...
Hi, try:
awk 'NR==FNR{A[$1,$2]; next} !(($2,$1) in A)' file file

--
Note: the file needs to be specified twice
1,075
Posted By durden_tyler
A different approach using Perl: $ $...
A different approach using Perl:


$
$ cat data.txt
Glyma.10G051100 Glyma.02G036000 89.91 228 23 0 1 228 1 228 1e-78 294
Glyma.10G051100 Glyma.09G023700 87.28 228 29 0 1 228 1 228 1e-68 261...
1,517
Posted By Don Cragun
Try this slight modification to your previous...
Try this slight modification to your previous script. It produces two output files. The matched pairs of input lines will be written to the file named matched and the remaining input lines will be...
1,517
Posted By RudiC
So, that's a catch22, isn't it? How about posting...
So, that's a catch22, isn't it? How about posting the smallest possible set of test data that shows the problem?
849
Posted By RudiC
How about awk 'K[$1,$2] != $3; {K[$2,$1] =...
How about
awk 'K[$1,$2] != $3; {K[$2,$1] = $3}' file
A1 B1 100.00
A2 B2 90.80
A3 B3 99.07
A4 B4 99.00
A5 B5 97.13
B5 A5 99.53
Ax By i
By Ax j
1,526
Posted By RavinderSingh13
Hello nengcheng, Could you please try...
Hello nengcheng,

Could you please try following and let me know if this helps you.
In case your Input_file has always string named Gly in it then following may help you in same.

awk...
1,526
Posted By durden_tyler
$ $ cat dataset.txt Gly1 Gly2 2 1 0 ...
$
$ cat dataset.txt
Gly1 Gly2 2 1 0
Gly3 Gly4 3 4 5
Gly3 Gly5 1 3 2
Gly2 Gly1 3 6 2
Gly4 Gly3 2 2 1
Gly6 Gly4 4 2 1
$
$ perl -lane 'if (defined $x{"@F[1,0]"}){print...
1,526
Posted By vgersh99
awk 'FNR==NR {a[$1,$2]=$0;next} (($2,$1) in a)' ...
awk 'FNR==NR {a[$1,$2]=$0;next} (($2,$1) in a)' myFile myFile
1,526
Posted By Don Cragun
You don't need to read the file twice... Try...
You don't need to read the file twice... Try also:
awk '
($1, $2) in x {
print x[$1, $2]
print
delete x[$1, $2]
next
}
{ x[$2, $1] = $0
}' dataset
If you want to try this on a...
2,419
Posted By vgersh99
awk '$1==$2' myFila
awk '$1==$2' myFila
Showing results 1 to 25 of 25

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