1

I'm trying to create archive file. the folder contains files with Russian names. these names are not saved correctly in the archive. Is there a way to save these names in Russian using "tar" or some other command?

myDate=$(date +"%Y%m%d")
myTime=$(date +"%H%M%S")

cd /data/folder1
tar -czvf /data/folder2/folder1_$myDate'_'$myTime.tar.gz *
TimeTq
  • 111
  • 1
  • 1
  • 3
  • Does this answer your question? [When to wrap quotes around a shell variable?](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) – Léa Gris Jul 25 '20 at 18:59
  • You need to double-quote your variables like `tar -czvf "/data/folder2/folder1_${myDate}_${myTime}.tar.gz" *` – Léa Gris Jul 25 '20 at 19:00
  • 2
    Add output of `locale` to your question (no comment). – Cyrus Jul 25 '20 at 19:06
  • 3
    The quotes are not relevant. If the Russian names are not stored correctly, then there would appear to be a problem with inconsistent use of character sets. We can't answer that here without a lot more information. Also, because SO is about programming, this might better be asked on Unix+Linux. – John1024 Jul 25 '20 at 19:07
  • 1
    See also: [Encoding of filenames containing non-latin characters while extracting from .tar.gz packed by Ant tar task](https://stackoverflow.com/a/22830245/7939871) – Léa Gris Jul 25 '20 at 19:07
  • Irrelevant to the root problem, but the first two lines could be consolidated as `myDateAndTime=$(date +%Y%m%d_%H%M%S)` and used `tar -czvf /data/folder2/folder1_$myDateAndTime.tar.gz *`. – M. Nejat Aydin Jul 26 '20 at 06:25

0 Answers0