A
A
Alexander F2020-01-30 14:29:00
bash
Alexander F, 2020-01-30 14:29:00

How to put a multiple path into a variable?

Hi all!
When writing a script, it became necessary to put several paths into one variable, i.e., for example:
var=/test/{fol1,fol2 ,
fol3
}
fol2,fol3 in the /test/ folder path, and creates directory 1 directory named {fol1,fol2,fol3}.
Tried double quotes, single quotes and backticks. Nothing helps. However, if you execute directly, then everything works.
mkdir /test/{fol1,fol2,fol3}.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Tallmange, 2020-01-30
@lex63

So fit?

#!/bin/bash

var=(/test/{fol1,fol2,fol3})
mkdir -p "${var[@]}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question