S
S
SOTVM2020-03-27 12:50:23
bash
SOTVM, 2020-03-27 12:50:23

How to substitute a variable in {}?

For example
~ $ x=$(seq -f %03g -s, 0 2);echo $x;
000,001,002

How to substitute $x into the echo {A..F}-{ $x } command so that it works like
~ $ echo {A..C}-{000,001,002}
A-000 A-001 A-002 B-000 B-001 B-002 C-000 C-001 C-002

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2020-03-27
@sotvm

x=$(echo {A..C}-{000..002})
# A-000 A-001 A-002 B-000 B-001 B-002 C-000 C-001 C-002

V
Viktor Taran, 2020-03-27
@shambler81

echo $($(A..F)-$(seq -f %03g -s, 0 2))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question