![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning output to a variable | jpmena | Shell Programming and Scripting | 3 | 03-27-2008 01:39 AM |
| assigning values to a variable | trichyselva | UNIX for Dummies Questions & Answers | 3 | 12-13-2007 10:55 PM |
| Assigning Value of variable | janemary.a | Shell Programming and Scripting | 2 | 05-11-2007 02:53 AM |
| assigning variable value using echo | shellburger | Shell Programming and Scripting | 2 | 07-11-2005 08:52 AM |
| assigning a variable containing hostname | esham | Shell Programming and Scripting | 4 | 03-07-2005 09:00 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Assigning a value to variable
Another newbie to Unix scripting Q..
How do you assign a value resulting from a command, such as awk, to a variable. I am currently trying:- $awk '{print $1}' file1 > variable1 with no change to $variable1. The line: $awk '{print $1}' file1 does print the first line of the file, so this is not an issue... Cheers |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
In ksh:
Code:
var=`awk '{print $1}' yourfile`
Regards, Tayyab |
|
#3
|
|||
|
|||
|
Ah ok, my file only has one column per line in any case, so it is not an issue here.
|
|
#4
|
|||
|
|||
|
Thanks shereenmotor, adding ` ` around the awk statement allows the variable to take the result value of that statement.
|
|||
| Google The UNIX and Linux Forums |