Hi,
how do you append to a variable? I can only get it to work with a seperate file like this:

printf $number1 >> sum.txt

I tried this :

$number1 >> $sum

but it says $sum: ambiguous redirect, any ideas? :)

Recommended Answers

All 3 Replies

Hey there,

For scripting in shell, you can just concatenate the two variables

sum="hi "
host # number1="there"
host # echo $sum
hi
host # sum="${sum}$number1"
host # echo $sum
hi there

Hope that helps :)

, Mike

That works great thanks :D

Cool. Glad to help out :)

. Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.