![]() |
|
|
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 |
| Storing the contents of a file in a variable | proactiveaditya | Shell Programming and Scripting | 6 | 10-28-2009 12:24 PM |
| read contents of a file with serveral lines & assign it to a variable | satyam.sumit | Shell Programming and Scripting | 2 | 09-10-2009 09:26 AM |
| Remove spaces from first field, and write entire contents into other text file | carriehoff | Shell Programming and Scripting | 3 | 11-11-2008 02:45 PM |
| put the contents of this file into a variable with multiple lines | Nomaad | Shell Programming and Scripting | 3 | 04-23-2008 01:39 AM |
| Strip leading and trailing spaces only in a shell variable with embedded spaces | jerardfjay | Shell Programming and Scripting | 6 | 03-07-2005 02:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I suppose the easiest way to explain my problem is to show you some code and then show you what the code outputs:
-------------------------------------------------- #!/bin/bash echo "This line has spaces" > "/tmp/This Filename Has Spaces.txt" export Foo=$(cat "/tmp/This Filename Has Spaces.txt") VarName=Bar export $VarName=$(cat "/tmp/This Filename Has Spaces.txt") echo $Foo echo $Bar -------------------------------------------------- This is the output: This line has spaces This How do I get the "Bar" variable to output the full string? Thanks so much! |
|
||||
|
It might help if u were to explain what you were trying to accomplish and I might be able to help further. However, in the examples you outlined try adding the following lines at the beginning of the script :
CFS=$IFS IFS=$(echo) and then add the following at the end of the script to set the IFS (Internal Field Separator) back. IFS=$CFS Should look like this ----------------------------- #!/bin/bash CFS=$IFS IFS=$(echo) echo "This line has spaces" > "/tmp/This Filename Has Spaces.txt" export Foo=$(cat "/tmp/This Filename Has Spaces.txt") VarName=Bar export $VarName=$(cat "/tmp/This Filename Has Spaces.txt") echo $Foo echo $Bar IFS=$CFS Output will look like this : This line has spaces This line has spaces |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|