Question
Hello Using Bash-Linux I want to write a script where, I input a file (myfile) where there are 4 columns of data: year inf1 inf2
Hello
Using Bash-Linux
I want to write a script where, I input a file (myfile) where there are 4 columns of data:
year inf1 inf2 data
2022 aaaa xxxx 7.2 2022 bbbb zzzz 8.1 2022 cccc vvvv 4.1 2022 dddd ssss 4.1 ...............
2022 eeee www 8.0
I want to redirect to the same file a (5th) column where I calculate the log10 of the 4th column(data). And then from the 5th column I just calculate, I want to add a number, numb (input by the user)
So what I have until know is:
infile="myfile"
awk '{print log($4)/log(10);}' $myfile >> $myfile
awk '{var=($5 + $var) ; print var}' $myfile >> $myfile
So I want in the end to have a file same as the input file (my file) plus two more columns with my calculations.
But my method doesn't work. So how can I direct to the same file. >> tee command doesn't work always and sponge command doesn't work at all.
Any help, please?
Thank you in advance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started