Skip to content Prejsť na obsah


Bash one liner – how to compress, move, and extract a directory Bash jeden liner - ako na komprimáciu, presunúť a výpis adresára

Linux

The other day I needed to migrate a directory containing a lot of files from one location on my Linux server to another. Onehdy som potreboval preniesť adresáre, ktoré obsahujú veľké množstvo súborov z jedného miesta na svojom serveri Linuxu na iný. There are a number of ways I could do this. Existuje niekoľko spôsobov, ako by som mohol urobiť. Using a simple cp command could have done the trick. Pomocou jednoduchého príkazu cp mohli urobiť trik. 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. Avšak, ako som bol kopírovanie dát bola databáza a chcel som, aby sa ubezpečil, že kopírovanie prebehlo perfektne, som sa pozrel na internet a našiel skvelý jeden riadok bash riešenia.

I wanted to move the contents of the directory /var/lib/mysql to /opt/mysql . Chcel som presunúť obsah adresára / var / lib / mysql do / opt / mysql. First I changed to the directory /var/lib/mysql : Najprv som zmenil do adresára / var / lib / mysql:

# cd /var/lib/mysql # Cd / var / lib / mysql

Then I ran the following one liner to do the magic for me. Potom som bežal za jedno lodných urobiť kúzlo pre mňa.

# 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. Použil som príkaz uvedené vyššie, kopii moje súbory databáz. 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. Čo to urobí, je to komprimuje celý obsah aktuálneho adresára, zmeny umiestnenie cieľového adresára (/ opt / mysql v tomto prípade), a potom extrahuje archív.

Posted in Publikované v Linux Linux . .

Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Help jednoduchá cvičenie, rovnako ako to vo vašej e-mailovej schránky každý deň - zadarmo! Just enter your email address below: Stačí zadať e-mailovú adresu:

You can always opt out of this email subscription at any time. Vždy sa môžete odhlásiť z tohto e-mailu predplatného kedykoľvek.

2 Responses 2 Citlivosť

Stay in touch with the conversation, subscribe to the Zostať v kontakte s konverzácia, prihláste sa RSS feed for comments on this post RSS kanál pre komentáre k tomuto príspevku . .

Continuing the Discussion Pokračovanie Diskusia

  1. More secure CLI file copy « Linux & Stuff Bezpečnejšie CLI kopírovanie súborov "Linux & Stuff linked to this post on May 28, 2009 súvisiacich s touto poštou dňa 28.května 2009

    [...] in Uncategorized Interesting post from Simplehelp where the following command is recommended to copy a large database from one location to [...] [...] V Nekategorizované Zaujímavý príspevok z Simplehelp, kde je nasledujúci príkaz odporúča kopírovať veľké databázy z jedného miesta na [...]

  2. How to setup slow query logging in MySQL | TuxWire : The Linux Blog Ako nastaviť pomalý dotaz prihlásení do MySQL | TuxWire: Linux Blog linked to this post on September 22, 2009 súvisiacich s touto poštou dňa 22.září 2009

    [...] Bash one liner – how to compress, move, and extract a directory [...] [...] Bash jeden fólie - ako na komprimáciu, pohyb, a výpis adresára [...]



Some HTML is OK Niektoré HTML je v poriadku

or, reply to this post via alebo odpovede na tento príspevok prostredníctvom trackback Trackback . .