Thanks for your valuable time and suggestion .This command works fine.
• 0 views
•
link
I have a file with arrangement shown below
A 0.5 0.2 0.4 0.8 0.3
B 0.2 0.8 0.7 0.0 0.6
C 0.8 0.2 0.1 0.4 0.7
And so on with around 8000 columns.
Now i don't know how to subtract these values in the column from 1 i.e.
Results
A 0.5 0.8 0.6 0.2 0.7
B 0.8 0.2 0.3 1.0 0.4
C 0.2 0.8 0.9 0.6 0.3
Please help me out solving this issue?
Let's suppose your values are stored in a file called file.txt. A simple awk command to achieve your objective would be:
awk '{for(i=2;i<=NF;i++){$i = 1 - $i}} {print $0}' file.txt > output.txt
It basically loops all the columns (NF field) of each row starting from the second column, it substitutes their values with 1 - value and then prints the entire line.
Thanks for your valuable time and suggestion .This command works fine.
Log in to answer this question.
Your post is confusing esp expected output.
Thank you for your quick suggestion.
So, if the input is like
A 0.4
Then what i want is
A 0.6
And that is 1-0.4 =0.6 .
Hope i cleared the confusion.