Search Results

Search: Posts Made By: perl_beginner
1,340
Posted By disedorgue
No, work just for power of 10 like...
No, work just for power of 10 like 10,100,1000,...
General case could be (example with range 30 by 30):
awk '{X=sprintf("%1.0d",($1+29)/30);A[X*30]+=$2};END{for (i in A){print i,A[i]}}'...
1,340
Posted By disedorgue
Hi, Can you try: awk...
Hi,
Can you try:
awk '{X=sprintf("%i00",($1+99)/100);A[X]+=$2};END{for (i in A){print i,A[i]}}' fileRegards.
1,599
Posted By RudiC
Try also awk ' {split ("", SUM) ...
Try also
awk '
{split ("", SUM)
n = split ($0, T1, /[MID]/)
m = split ($0, T2, /[0-9]+/)
for (i=n-1; i>0; i--) SUM [T2[i+1]]+=T1[i]
print $0,...
1,599
Posted By RavinderSingh13
Hello perl_beginner, Thank you for posting...
Hello perl_beginner,

Thank you for posting your approach to solve this problem. Please always do post the codes which you have tried to solve your problem, even they are not working ones, it is...
2,209
Posted By zaxxon
danmero's answer is a tad more intelligent than...
danmero's answer is a tad more intelligent than mine but what did not work with mine? I am curious to know, just in terms of interesst and politeness, thanks :)
1,242
Posted By RudiC
You didn't answer my question for your own...
You didn't answer my question for your own efforts. Anyhow, try
awk '{for (i=0; i<$3; i++) print substr($1, i+1, 1), $2+i}' file
1,242
Posted By vgersh99
something along these lines: awk '{ for(i=0;...
something along these lines:

awk '{ for(i=0; i<$3; i++) print substr($1,i+1,1), $2+i}' myFile
1,242
Posted By RudiC
You seem to mix up rows and colums? Any...
You seem to mix up rows and colums?

Any attempts/ideas/thoughts from your side?
1,419
Posted By RudiC
Try an adaption of RavinderSingh13's fine...
Try an adaption of RavinderSingh13's fine proposal:

awk '
{$3 = $1
while (match ($3, /N*N/)) $3 = substr($3, 1, RSTART-1) substr($2, RSTART, RLENGTH) substr($3, RSTART+RLENGTH)...
1,419
Posted By RavinderSingh13
Hello perl_beginner, Sorry, I didn't see the...
Hello perl_beginner,

Sorry, I didn't see the point like it is same position in column 2 where you want to get the replacements, so could you please try following.

awk...
1,419
Posted By RavinderSingh13
Hello perl_beginner, Thank you for asking...
Hello perl_beginner,

Thank you for asking good question, please keep it up. Coming to your requirement now, off course SHELL can't understand you BOLD characters(which you actually made for us to...
1,266
Posted By jim mcnamara
try: sort -T . -k3n -t_ -k7 infile >...
try:

sort -T . -k3n -t_ -k7 infile > outfile

I get:

$ sort -T . -k3n -t_ -k7 filename
DN133_c0_g1 DN133_c0_g1_i1
DN134_c0_g1 DN134_c0_g1_i1
DN63688_c0_g1 DN63688_c0_g1_i1...
1,266
Posted By Don Cragun
Try: sort -T . -k1.3n -t_ -k6.2n Input_File
Try:
sort -T . -k1.3n -t_ -k6.2n Input_File
8,160
Posted By RudiC
Orawk '{$2+=0}1' CONVFMT="%.2f" file
Orawk '{$2+=0}1' CONVFMT="%.2f" file
8,160
Posted By RudiC
Try awk '{print $1, $2+0}' OFMT="%.2f" file USA...
Try awk '{print $1, $2+0}' OFMT="%.2f" file
USA 20.57
UK 3.54
Japan 2.54
China 2.51
Germany 2.06
958
Posted By RudiC
How about sort -k1,1 -k2,2n file
How about sort -k1,1 -k2,2n file
958
Posted By Don Cragun
If you really want to keep column 1 as it is and...
If you really want to keep column 1 as it is and sort the 2nd and 3rd columns by increasing numeric value of the 2nd column (instead of sorting column 2 values with column 1 values, you could try:...
1,228
Posted By RudiC
Try alsoawk ' $1 != LAST {if (NR != 1)...
Try alsoawk '
$1 != LAST {if (NR != 1) printf "%s", RS
printf "%s", $0
LAST = $1
next
}
{printf ",%s",...
1,228
Posted By RavinderSingh13
Hello perl_beginner, If you are not bothered...
Hello perl_beginner,

If you are not bothered about the output's sequence(Means it may differ from the Input_file input sequence), then following may help you.

awk '{A[$1]=A[$1]?A[$1] OFS...
4,236
Posted By RavinderSingh13
Hello perl_beginner, Could you please try...
Hello perl_beginner,

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

awk 'BEGIN{j=4124;for(i=1;i<=4124;i++){A[i]=i;B[i]=j;j--};for(k in A){print A[k] OFS...
4,236
Posted By wisecracker
OSX 10.7.5, default terminal using 'sh'. Try:- ...
OSX 10.7.5, default terminal using 'sh'.
Try:-
#/bin/sh
for n in {1..416}
do
echo "$(( ( $RANDOM % 4124 ) + 1 )) $(( ( $RANDOM % 4124 ) + 1 ))"
done
4,236
Posted By RudiC
You're not too far off! Try awk...
You're not too far off! Try awk "BEGIN{srand($RANDOM); for(i=1;i<416;i++)print int(1+ rand()*4124), int(1+rand()*4124)}"
1931 3259
1456 1559
150 357
.
.
.
1,697
Posted By RudiC
Replace print by {print; next}.
Replace print by {print; next}.
1,697
Posted By RavinderSingh13
Hello perl_beginner, RudiC has given code a...
Hello perl_beginner,

RudiC has given code a non one-liner so when you run it should run fine as follows(though I am not having same OS as you, just seeing your error I am predicting it.). In one...
1,100
Posted By Aia
Hi looney, All the highlighted part is...
Hi looney,

All the highlighted part is pattern, so it will be the equivalent of:
NR > 1 && $0=B"#"A {print $0}
If every term of the pattern evaluates to true print the whole record. The...
Showing results 1 to 25 of 171

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