Filip Banák
Filip Banák

Reputation: 23

How to combine text with expanded variable into a variable expansion in fish

I need to echo the value of $bootlog1 through $bootlog5.

Something like this:

for n in (seq 5)
    set bootlog$n value
    echo $bootlog$n
end

But I can't seem to figure it out.

Upvotes: 2

Views: 60

Answers (1)

glenn jackman
glenn jackman

Reputation: 247092

Easier to use an intermediary variable:

for n in (seq 5)
    set var bootlog$n
    set $var (random)
    echo $var = $$var
end
bootlog1 = 20819
bootlog2 = 19479
bootlog3 = 11254
bootlog4 = 23223
bootlog5 = 23674

Upvotes: 4

Related Questions