![]() |
|
|
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 |
| variable not retaining value | gillbates | Shell Programming and Scripting | 5 | 11-16-2005 06:16 PM |
| Length of a variable | karyn1617 | Shell Programming and Scripting | 3 | 02-08-2005 06:41 PM |
| Parsing a variable length record | Barb | UNIX for Dummies Questions & Answers | 17 | 10-01-2004 09:37 AM |
| length of data greater than 11 | thanuman | UNIX for Dummies Questions & Answers | 2 | 09-10-2004 08:13 AM |
| creating a fixed length output from a variable length input | r1500 | Shell Programming and Scripting | 2 | 12-03-2003 01:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Parsing data and retaining the full length of variable
Here's is an example of what I want to do:
var1="Horse " var2="Cat " var3="Fish " for animals in "$var1" "$var2" "$var3" do set $animals pet=$1 ## Ok, now I want to get the values of $pet, but ## I want to retain the full length it was originally in ## var1, var2 or var3, say it was 10 bytes. If I then do ## the following: echo "$pet : " The printing of this(the colons in this example) will not line up: Horse : Cat : Fish : I think I have done this before, but it is Friday and my brain is fried.....any help would make my weekend! Thanks |
|
||||
|
you need to double quote all those variables carrying animals including the positional parameter $1...
try this... Code:
var1="Horse "
var2="Cat "
var3="Fish "
for animals in "$var1" "$var2" "$var3"
do
set "$animals"
pet="$1"
echo "$pet :"
done
Vishnu. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|