Skip to content Перейти до змісту


Bash one liner – how to compress, move, and extract a directory Баш Один балон - як стиснути, переміщати і екстракт каталозі

Linux

The other day I needed to migrate a directory containing a lot of files from one location on my Linux server to another. Днями мені потрібно перейти в каталог, що містить безліч файлів з одного місця на моєму сервері Linux на іншій. There are a number of ways I could do this. Є кілька способів я міг би це зробити. Using a simple cp command could have done the trick. За допомогою простої команди CP міг зробити трюк. However, as the data I was copying was a database and I wanted to make sure that the copying was done perfectly, I looked on the Internet and found a brilliant one line bash solution for this. Однак, оскільки дані я була копіювання бази даних, і я хотів, щоб переконатися, що копіювання було зроблено чудово, я подивився в Інтернеті і знайшли блискуче одному рядку Bash рішення для цього.

I wanted to move the contents of the directory /var/lib/mysql to /opt/mysql . Я хотів, щоб перемістити вміст каталогу / VAR / LIB / MySQL в / Opt / MySQL. First I changed to the directory /var/lib/mysql : Спочатку я змінив у директорію / VAR / LIB / MySQL:

# cd /var/lib/mysql # CD / VAR / LIB / MySQL

Then I ran the following one liner to do the magic for me. Тоді я побіг наступні Один балон зробити магію для мене.

# tar cf – * | ( cd /opt/mysql; tar xfp -) # TAR CF - * | (CD / Opt / MySQL; TAR XFP -)

I used the command shown above to copy my database files. Я використовував команду показано вище, щоб скопіювати мої файли бази даних. What it does is it compresses the entire contents of the current directory, changes to the location of the destination directory ( /opt/mysql in this case), and then extracts the archive. Що вона робить, це він стискає весь вміст поточного каталогу, зміни до місця призначення каталозі (/ Opt / MySQL в даному випадку), а потім витягує архів.

Posted in Опубліковано в Linux Linux . .

Get Simple Help tutorials just like this one in your email inbox every day - for free! Отримати довідки Прості підручників, як це у вашому поштовому ящику щодня - безкоштовно! Just enter your email address below: Просто введіть свою адресу електронної пошти нижче:

You can always opt out of this email subscription at any time. Ви завжди можете відмовитися від підписки це повідомлення в будь-який час.

2 Responses 2 Відповіді

Stay in touch with the conversation, subscribe to the Залишайтеся на зв'язку при розмові, підпишіться на RSS feed for comments on this post RSS-канал для коментарів на цю посаду . .

Continuing the Discussion Продовжуючи розмову

  1. More secure CLI file copy « Linux & Stuff Більш безпечна CLI копії файлу «Linux & Stuff linked to this post on May 28, 2009 пов'язані на цю посаду 28 травня 2009

    [...] in Uncategorized Interesting post from Simplehelp where the following command is recommended to copy a large database from one location to [...] [...] В рубрицi Цікавий пост від Simplehelp де такі команди рекомендується скопіювати великої бази даних з одного місця в [...]

  2. How to setup slow query logging in MySQL | TuxWire : The Linux Blog Як налаштувати журнал повільних запитів в MySQL | TuxWire: Linux блог linked to this post on September 22, 2009 пов'язані на цю посаду 22 вересня 2009

    [...] Bash one liner – how to compress, move, and extract a directory [...] [...] Вдаритися Liner - як стиснути, переміщати і екстракт каталозі [...]



Some HTML is OK Деякі HTML нормально

or, reply to this post via або відповісти на цей пост через trackback Архів . .