Type to search…

Arxivar

Molts cops has d'arxivar un conjunt de fitxers en un de sol, comprimir un fitxer que no fas servir perquè ocupi menys espai, o fer les dues coses a la vegada.

This page hasn't been translated yet — shown in its original language:Català

Introducció

Arrenca una màquina virtual Linux amb Windows Subsystem for Linux (WSL).

ps
> connect-wsl archive -new

Empaquetar

tar és un programa que permet empaquetar un conjunt de fitxers en un sol fitxer.

El nom “tar” prové de la frase “Tape ARchive”, que era un cinta on es guardaven dades:

I avui en dia encara es fan servir les cintes per guardar dades en volums de Terabytes.

Crear

Crea dos fitxers:

shell
$ echo "one" > one.txt
$ echo "two" > two.txt

A continuació guarda els fitxers en el fitxer numbers.tar amb el flag c (create):

shell
$ tar cf numbers.tar one.txt two.txt

El flag f (file) és necessari per indicar a tarel fitxer que ha de crear.

Si no passes el flag f, tarprotesta:

shell
$ tar c numbers.tar one.txt two.txt 
tar: Refusing to write archive contents to terminal (missing -f option?)
tar: Error is not recoverable: exiting now

You're reading a preview.

Sign in with Google to read the full page. Follow the learning path — each page opens once you've read the ones it builds on. Students and teachers read their course pages without limit.

Sign in