![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning output to a variable | jpmena | Shell Programming and Scripting | 3 | 03-27-2008 04:39 AM |
| Assigning output of command to a variable in shell | sankar reddy | Shell Programming and Scripting | 6 | 02-28-2008 03:01 AM |
| assigning nawk output to shell variable | user_prady | Shell Programming and Scripting | 6 | 11-29-2007 04:01 AM |
| assigning command output to a shell variable | kprattip | Shell Programming and Scripting | 2 | 07-09-2007 05:01 AM |
| Command output to a variable. | videsh77 | Shell Programming and Scripting | 8 | 12-16-2004 06:06 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Assigning output of command to a variable
Hi,
I'm trying to assign the output of a command to a variable and then concat it with another string, however, it keeps overwriting the original string instead of adding on to the end of the string. Contents of test.txt --> This is a test var1="`head -n 1 test.txt`" echo $var1 (This is a test) var1=$var1"123" echo $var1 (123s is a test [instead of: This is a test123) The issue has something to do with the first line. If I simply assign a string like this: var1="This is a test" , then it all works, but when I try to assign the output of a command to a variable, it does not add to the string properly. Does anyone know how to get around this?? Thanks!! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|