I'm relatively new to bash scripting and am trying to use awk inside a bash for loop but am having a problem with the variables.
The echo command reads out the variables correctly but the next awk command can't read them. I've tried having the variables with and without the $ to no avail.
I'd also like to print all of this to a file at the end with the first column being profile$i and the second being the final value of sum/NR but again I am not sure how to do this.
$up and $down in the awk script won't be expanded due to the single quotes. Be careful - in the script, $1 et al. are awk fields, not the shell script's positional parameters. And why do you use that dangerous (eval!) and cumbersome method to define the two variables? $i will not be available within awk - see above (will not be expanded, and if, would be an internal field). Nor will the shell arithmetic expression work.
awk is not part of bash. awk is its own separate, independent language. Variables defined in BASH won't be defined in AWK unless you bring them in with -v VAR= at the beginning or VAR=... at the end.
If you run awk 5 times, you will be running it 5 independent times, with variables not carried between.
Variables inside single quotes ' ' do not expand -- and since awk code uses $ for column instead of variable, you don't want them to expand! The shell would eat them all and change the meaning of the awk code.
There's a couple ways to put variables into awk, none of which is embedding them inside the program itself.
awk does not need cat's help to read a file. You do this without the cat earlier, I'm not sure why you add it later.
Your awk code can be simplified so you only run it once instead of twice, and to get rid of the 'junk' file completely.
I am trying to check whether particular host and port are responding or not. I am using below script to check. but node_port array that i am using in loop is getting replaced with previous iteration value. Script and output is given.
Please help me to understanding why node_port values are... (5 Replies)
I have created one file that contains all the necessary info in it to create a download link. In each of the lines /results/analysis/output/Home/Auto_user_S5-00580-6-Medexome_67_032/plugin_out/FileExporter_out.67... (8 Replies)
Hi
My goal is to fill an HTML form and submit.
What I have managed to do:
1. curl command to fill up the form and submit
2. a file which has the input
curl command:
curl -v -b cookie.txt -d __CSRFToken__=dc23d5da47953b3b390ec68d972af10380908b14 -d do=create -d a=open -d... (10 Replies)
Hello experts!
I have a file1 with the following format (yr,day, month, hour,minute):
201201132435
201202141210
201304132030
201410100110
...
What i want to do is to assign variables and then use them in the curl command to download the text of each event from a web page.
What I have... (6 Replies)
I have a file as follows:
0
1056
85540
414329
774485
1208487
1657519
2102753
2561259
3037737
3458144
3993019
4417959
4809964
5261890
5798778
6254146
I want to find all lines between a specified start and end tag. (6 Replies)
Hi,
I have the following folder structure:
TST500-1000
TST500-2000
TST500-3000
TST700-1000
TST700-2000
TST700-3000
TST900-1000
TST900-2000
TST900-3000
I would like to store the numbers in the first column (considering "-" as column separator) into a variable then the numbers in... (3 Replies)
ok this is probably going to turn out to be something really stupid but i've tried to use the following command in a script but the output is just a blank screen and i have to use Ctrl c to exit it.
awk 'BEGIN {printf "%.2f\n", '${bashArray}'>='$Variable' {print '${bashArray}'}}'
the command... (2 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Hi all-
I've been fooling with this for a few days, but I'm rather new at this...
I have a bash variable containing a long string of various characters, for instance:
JUNK=this that the other xyz 1234 56 789
I don't know what "xyz" actually is, but I know that:
START=he other
and ... (2 Replies)