S
S
swim3r2019-07-29 13:19:13
linux
swim3r, 2019-07-29 13:19:13

How to escape folder names in tar?

Good afternoon.
There is a bash script that starts archiving folders for ELK.
Folder names are generated from random characters, and when the folder starts with "-". For example "-32JUVRKW5Qx9MrF49oQ". Then tar takes the next character as an option, and crashes accordingly.
Team "

tar -cvzf $ARCHIV_DIR/$ARCHIV_DATA.tar.gz -C /srv/lib/elasticsearch/nodes/0/indices/ $INDICES
". Where $INDICES are folder names like "Bu894OCDRBWxupAuIPKrcg n1cWAfXYRvaszRwvvcN2IQ 9_9CDKEuTJ-OkXdidplEUg,
etc.
"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2019-07-29
@swim3r

tar -cvzf $ARCHIV_DIR/$ARCHIV_DATA.tar.gz -C /srv/lib/elasticsearch/nodes/0/indices/ -- $INDICES

Example:
$ tar cvf 1 -- x y -wow
x/
x/1.txt
y/
y/1.txt
-wow/
-wow/1.txt
 
And here -w was perceived as an option
$ tar cvf 1 x y -wow
add ‘x’?^C

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question