Jotne, thanks for checking & suggestions:
Yes, awk can goes upto 170 only,
- I have cheked with hp-ux version and linux suse versions too:
With the awk version Factorial:
170! Gives:
171! Gives: infinity.
Scrutinizer, thanks ,awk code works great thanks for making the awk version of factorial, seems there is a limitation of 171th calculation. But it is good to have the code .Thanks,
- For the first unix command based code with sed & bc:
Out of curiosity I tried Jotne's remark for n=1000 value and it worked like a charm .
Also wondered when I put it n=2000, we know factorial of 2000 is going to be huge, and this too worked on Suse 11.2 VM perfectly. It was kind of grabled the display at the 19xx as it was processing so quickly.
---------- Post updated at 06:08 PM ---------- Previous update was at 05:56 PM ----------
All, Out of curiosity I increased factorial value , n=2000 and it worked to:
Showing factorial of 2000 below :
on Linux Suse 11.2 VM , shell = /bin/bash
represents the range of the display:
Not sure how far it can go. Need to try sometime, but this looks amazing calculations by the cpu.
Thank you for sharing, rveri. I took the liberty of further distilling your contribution. The following use a subset of the tools used by your originals.
Regards,
Alister
Alister,
Thanks for the additional code it works fine, the seq -s is a great addition to it,
Further it is tried made as little as after shortened with the factorial notation:
Amazingly it works for factorial of 3000 also and so on....
It is amazing that it worked for 3000! also , but it used the top cpu it was 100% used, it was processing too fast.
Hi Guru's.
I am trying to use to check if $5 is greater than 80 & if not 100, then to print $0 :
awk '{ if ($5>80) && if ($5 != 100) print $0}
But getting error:
>bdf1|sed 's/%//g'|awk '{ if ($5>80) && if ($5 != 100) print $0}'
syntax error The source line is 1.
The error... (6 Replies)
Just want to know why when I do the following in sed, the required is not extracted.
echo "ab01cde234" | sed 's/*$//'
result: ab01cde (Which is correct)
echo "ab01cde234" |sed 's/.*\(*\)$/\1/'
result: blank (was expecting 234)
or
echo "ab01cde234" |sed 's/.*\(\)*$/\1/'
result: blank... (6 Replies)
I've seen in other programmers code the use of '_&' as a line separator. I am trying to find in my C++ reference manual some pages dedicated to an explanation of the use of this '_&' but I don't know what it is called. I only know it is a "line separator" or "line break" of some sort which is... (0 Replies)
We had a SAS70 audit at our site a few months back and part of the end result was that I had to install tripwire to monitor our application binaries. We were able to compile tripwire for our AIX 5.3 server but after a few months I was asked to install it on other systems. I could have and did just... (1 Reply)
Hello everyone,
i wonder if someone could give me an advice regarding the following problem using sed.
Given ist a structure as shown below:
<aaa>text1<b>text2</b>text3<c>text4</c>text5</aaa>
Now I want to change the outer tag from "aaa" to "new" and replace all tags inside the outer tags... (4 Replies)
I am trying to delete everything in the parenthesis(including the parenthesis) in this text:
Wind: from the WNW (290 degrees) at 6 MPH (5 KT)
Pressure (altimeter): 29.82 in. Hg (1009 hPa)
Temperature: 80.1 F (26.7 C)
Dew Point: 72.0 F (22.2 C)
Relative Humidity: 76%
Trying to make it look... (3 Replies)
hey,
Im just wondering is there away to get sed to read from a variable
eg
it doesn't seem to work, i really need to be able to recursively change the same data set... (2 Replies)
I have a line
EXTDIR=`echo $i | sed 's/\-tar.gz//'`
which looks for files ending in -tar.gz, i would like to increase the functionality so that it looks for .tar.gz files as well as -tar.gz. Do i put the - in square brackets with a dot ? like this
EXTDIR=`echo $i | sed 's/\tar.gz//'`
... (1 Reply)