[Solved] To the power of using awk


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] To the power of using awk
# 1  
Old 08-20-2013
[Solved] To the power of using awk

Hi Guys,
I got stuck to a a point where I need to find the value for (4 to the power of -2 upto 8 places after decimal ....

4^(-2) ; the result I need is upto 8 places after decimal.
How is that possible?

Thanks a lot!!
# 2  
Old 08-20-2013
Code:
awk 'BEGIN {printf("%.8f\n",4^-2)}'

This User Gave Thanks to krishmaths For This Post:
# 3  
Old 08-20-2013
Thanks a lot Krish Smilie

Moderator's Comments:
Mod Comment edit by bakunin: changed thread title accordingly.

Last edited by bakunin; 08-20-2013 at 07:44 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Calculate e raise to the power in awk | UNIX

Input data: I'd like to calculate using value in second column. The value needs to be created using a formula, that employs exp (that is e raise to the power). awk '{ if(FNR==1){ ##if first line than print as is and add third column print $0,"weight" } else{ if($2<=0.01){... (2 Replies)
Discussion started by: genome
2 Replies

2. UNIX for Dummies Questions & Answers

[Solved] awk oddity

I have to apologize for my ignorance so this question is probably stupid. How does awk process a file? Does it read from top of input file to end of file going line by line? Yoda helped me create an awk script that helps me parse the named.conf file and output it into a .csv file but when... (8 Replies)
Discussion started by: djzah
8 Replies

3. UNIX for Dummies Questions & Answers

[Solved] awk FS

I have a script which uses awk to read from a file seperated with commas, although saved as a .conf file. awk -F, '{print $3}' it is meant to pick up "a label here" (for example) But instead return "a" Problem is that although the command does recognise the comma seperation it still... (1 Reply)
Discussion started by: Pedro72
1 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Help with awk

Hi All, I have been using the below syntax in unix and it has been working fine, Later when we migrated to Linux by having folder wise pemission its not working fine. So can you let us know where the list file could be created ? awk '/^XXX/{key=$0;print > "list";next} /^YYY/ {print... (4 Replies)
Discussion started by: secretsanta.rci
4 Replies

5. Shell Programming and Scripting

[Solved] HP-UX awk sub multiple patterns

Hi, I am using sub to remove blank spaces and one pattern(=>) from the input string. It works fine when I am using two sub functions for the same. However it is giving error while I am trying to remove both spaces and pattern using one single sub function. Working: $ echo " OK => " |awk... (2 Replies)
Discussion started by: sai_2507
2 Replies

6. Shell Programming and Scripting

[Solved] awk string with spaces

Why does this work: awk -v s="this is a string" 'index($0, s)' file while the following doesn't? s="this is a string" awk -v s=$s 'index($0, s)' file How do I search for a string with spaces in it? ---------- Post updated at 01:18 AM ---------- Previous update was at 01:15 AM ----------... (0 Replies)
Discussion started by: locoroco
0 Replies

7. UNIX for Dummies Questions & Answers

[Solved] awk output into a file

Hello board members.. here i am and here is my question. OS HP-UX awk i have a file where the FS is the pipe (|). So i choose the second field and i would like to do the following: If this filed is 0 then, i need the line in file1.txt Else write the line in file2.txt cat testfile.txt |... (2 Replies)
Discussion started by: kiko
2 Replies

8. Shell Programming and Scripting

Solved: AWK SED HELP

Hi, I need to process a file as below. Could you please help to achieve that using awk/sed commands. Input file: --------------- AB | "abcdef 12345" | 7r5561451.pdf PQRST | "fghfghf hgkjgtjhghb ghhgjhg hghjghg " | 76er6ry.pdf 12345 | "fghfgcv uytdywe bww76 jkh7dscbc 78 : nvchtry hbuyt"... (0 Replies)
Discussion started by: viveksr
0 Replies

9. Shell Programming and Scripting

can this been solved with awk and sed?

Hi Masters, ___________________________________________________________________________________ Group of orthologs #1. Best score 3010 bits Score difference with first non-orthologous sequence - yeast:3010 human:2754 YHR165C 100.00% PRP8_HUMAN 100.00%... (16 Replies)
Discussion started by: mskcc
16 Replies
Login or Register to Ask a Question