Sponsored Content
Top Forums Shell Programming and Scripting Add a number all the the values and log transform them using awk Post 302922935 by RudiC on Wednesday 29th of October 2014 09:05:12 AM
Old 10-29-2014
Not the slightest attempt from your side?
Try
Code:
awk     'NR==1          {ln2=log(2); print; next}
                        {sum=0
                         for (i=2; i<=NF; i++)
                                {$i=log($i+1)/ln2
                                 sum+=$i}
                         for (i=2; i<=NF; i++)
                                $i/=sum
                        }
         1
        ' OFS="\t" CONVFMT="%.4g" file
name    c1      c2      c3      c4
r1      0       0.2334  0.3359  0.4307
r2      0       0       0       1
r3      1       0       0       0
r4      0       0       0.5     0.5
r5      0.3003  0.2729  0.2134  0.2134

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Use awk to log transform

Hello. I'm trying to use the awk command to convert certains fields to lgo base 2, not base 10. I'm trying command lines like: awk '$2 $5 $7 {print log(2)($2), log(2)($5), $7) filein.txt > fileout.txt I'm trying to make a deadline. Thanks for helping a newbie. Here's some fresh karma... (1 Reply)
Discussion started by: jmzcal
1 Replies

2. Shell Programming and Scripting

AWK help to add up sequential values

Hello All! As a beginner user i want to add up sequential values in a text file and want to print total sum as output.The Text file will have values like the following: class1{root}>less SUM.txt 1140.00 1155.00 1183.00 ... # it continues # i tried to write a... (1 Reply)
Discussion started by: EAGL€
1 Replies

3. UNIX for Dummies Questions & Answers

Using awk to log transform a column in a tab-delimited text file?

How do I use awk to log transform the fifth column of a tab-delimited text file? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

4. UNIX for Dummies Questions & Answers

How to log transform a text file?

How can I log transform (log 2) a text file which is a single column of numbers? (4 Replies)
Discussion started by: evelibertine
4 Replies

5. Shell Programming and Scripting

awk to search similar strings and add their values

Hi, I have a text file with the following content: monday,20 tuesday,10 wednesday,29 monday,10 friday,12 wednesday,14 monday,15 thursday,34 i want the following output: monday,45 tuesday,10 wednesday,43 friday,12 (3 Replies)
Discussion started by: prashu_g
3 Replies

6. Shell Programming and Scripting

SED/AWK to edit/add field values in a record

Hi Experts, I am new to shell scripting. Need some help in doing one task given by the customer. The sample record in a file is as follows: 3538,,,,,,ID,ID1,,,,,,,,,,, It needs to be the following: 3538,,353800,353800,,,ID,ID1,,,,,COLX,,,,,COLY, And i want to modify this record in... (3 Replies)
Discussion started by: sugarcane
3 Replies

7. UNIX for Dummies Questions & Answers

count number of distinct values in each column with awk

Hi ! input: A|B|C|D A|F|C|E A|B|I|C A|T|I|B As the title of the thread says, I would need to get: 1|3|2|4 I tried different variants of this command, but I don't manage to obtain what I need: gawk 'BEGIN{FS=OFS="|"}{for(i=1; i<=NF; i++) a++} END {for (b in a) print b}' input ... (2 Replies)
Discussion started by: beca123456
2 Replies

8. Shell Programming and Scripting

awk to log transform on matrix file

Hi Friends, I have an input matrix file like this Col1 Col2 Col3 Col4 R1 1 2 3 4 R2 4 5 6 7 R3 5 6 7 8 I would like to consider only the numeric values without touching the column header and the row header. I looked up on the forum's search, and I found this. But, I donno how to... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

9. Shell Programming and Scripting

Add values of similar patterns with awk

so my output is this: session_closed=157 session_opened=151 session_closed=18 session_opened=17 there are two patterns here, but with different values. the two patterns are "session_opened" and "session_closed". i expect there will be many more other patterns. what i want to do is... (8 Replies)
Discussion started by: SkySmart
8 Replies

10. Shell Programming and Scripting

awk to extract multiple values from file and add two additional fields

In the attached file I am trying to use awk to extract multiple values and create the tab-delimited desired output. In the output R_Index is a the sequential # and Pre_Enrichment is defaulted to .. I can extract from the values to the side of the keywords, but most are above and I can not... (2 Replies)
Discussion started by: cmccabe
2 Replies
transform(1)                                              GNU Triangulated Surface utils                                              transform(1)

NAME
transform - apply geometric transformations to the input. SYNOPSIS
transform [OPTIONS] < file.gts DESCRIPTION
This manual page documents briefly the transform command. OPTIONS
This program follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -r ANGLE, --rx=ANGLE Rotate around x-axis (ANGLE in degrees). -m ANGLE, --ry=ANGLE Rotate around y-axis. -m ANGLE, --rz=ANGLE Rotate around z-axis. -s FACTOR, --scale=FACTOR Scale by FACTOR. -R FACTOR, --sx=FACTOR Scale x-axis by FACTOR. -M FACTOR, --sy=FACTOR Scale y-axis by FACTOR. -N FACTOR, --sz=FACTOR Scale z-axis by FACTOR. -t V, --tx=V Translate of V along x-axis. -u V, --ty=V Translate of V along y-axis. -w V, --tz=V Translate of V along z-axis. -i, --revert Turn surface inside out. -o, --normalize Fit the resulting surface in a cube of size 1 centered at the origin. -v, --verbose Print statistics about the surface. -h, --help Display the help and exit. AUTHOR
transform was written by Stephane Popinet <popinet@users.sourceforge.net>. This manual page was written by Ruben Molina <rmolina@udea.edu.co>, for the Debian project (but may be used by others). June 2, 2008 transform(1)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy