bash script read error and awk ouptut error
$y=5
read -p MNAME ## ERROR DOES NOT READ awk '//{print $2, $(($1/$y))}' ## ERROR does not divide here are the two lines I have narrowed my errors down 2. Project is due in 1 hr |
I don't get it what do you want to do?
|
assignment to and use of variables in borne style shells is done like this:
Code:
myvar="my value" Code:
echo 'myvar is $myvar' Code:
myvar is $myvar Code:
echo "myvar is $myvar" Code:
myvar is my value |
To add to matthew's post:
To get to a shell variable in awk assign it to an awk variable on invocation of awk Code:
awk -v y=$y '{print $2, $(($1/y))}' Cheers, Tink |
## read with prompt. The prompt you used is "MNAME " assignment is by default to the reserved variable REPLY.
## if you wish to assign to a variable it should follow the prompt. ## you can assign to a number of variables with: ## read -p "MYPROMPT " var1 var2 varjunk ## that will assign the first variable into var1 the second into var2 and all further into varjunk Quote:
Quote:
## Tinker, I admit to not understanding the $(( )) construct within the awk code. ## The ( ) to force an expression is good for me. perhaps Tinker can enlighten us please. ## I never write code, I develop it. That is to say I regularly put in echo and print statements to prove anything and everything as I progress to ensure that all assumptions I make are tested during the coding. I throw away probably 5/6 or more of what I write, because I don't write it every day to be as familiar as I aught to be. ## Oh, and a problem shared is someone elses! If your project is going overtime, don't hide it but tell your manager. He might not be too happy at the prospect, but to get someone else to do the job won't be practical and once he knows about it, then he isn't going to be set upon by a client demanding answers and not knowing the score. As soon as he says, "ok hurry it up", then the pressure is off of you and on the manager. ## Have a happy project. ## PAix |
All times are GMT -5. The time now is 03:53 AM. |