Làm cách nào để đặt nhiều tệp vào nhiều thư mục trong Linux?

Để kết hợp nhiều tệp thành một tệp lưu trữ duy nhất [ví dụ:

tar -cvf my_files.tar /path/to/my/directory
6], hãy sử dụng lệnh sau [thay thế
tar -cvf my_files.tar /path/to/my/directory
7 và
tar -cvf my_files.tar /path/to/my/directory
8 bằng tên của các tệp bạn muốn kết hợp]

tar -cvf my_files.tar file1 file2

Để kết hợp tất cả các tệp trong một thư mục thành một tệp lưu trữ duy nhất [ví dụ:

tar -cvf my_files.tar /path/to/my/directory
6], hãy sử dụng lệnh sau [thay thế
tar -cvzf my_files.tar.gz file1 file2
0 bằng đường dẫn tuyệt đối đến thư mục chứa các tệp bạn muốn kết hợp]

tar -cvf my_files.tar /path/to/my/directory

Ghi chú

  • Bạn có thể sử dụng bất kỳ tên nào thay cho
    tar -cvf my_files.tar /path/to/my/directory
    
    6, nhưng bạn nên giữ phần mở rộng
    tar -cvzf my_files.tar.gz file1 file2
    
    2
  • Nếu bạn không sử dụng tùy chọn
    tar -cvzf my_files.tar.gz file1 file2
    
    3, thì
    tar -cvf my_files.tar /path/to/my/directory
    
    2 sẽ cho rằng bạn muốn tạo một kho lưu trữ băng từ thay vì kết hợp một số tệp
  • Tùy chọn
    tar -cvzf my_files.tar.gz file1 file2
    
    5 yêu cầu
    tar -cvf my_files.tar /path/to/my/directory
    
    2 dài dòng [báo cáo tất cả các tệp khi chúng được thêm vào]

Tạo một tệp lưu trữ nén

Nhiều bản phân phối Linux sử dụng GNU

tar -cvf my_files.tar /path/to/my/directory
2, một phiên bản của
tar -cvf my_files.tar /path/to/my/directory
2 do Tổ chức Phần mềm Tự do< . Nếu hệ thống của bạn sử dụng GNU
tar -cvf my_files.tar /path/to/my/directory
2, bạn có thể sử dụng
tar -cvf my_files.tar /path/to/my/directory
2 kết hợp với tiện ích nén tệp
tar -cvf my_files.tar /path/to/my/directory
4 để kết hợp nhiều tệp vào một tệp lưu trữ nén.
. If your system uses GNU
tar -cvf my_files.tar /path/to/my/directory
2, you can use
tar -cvf my_files.tar /path/to/my/directory
2 in conjunction with the
tar -cvf my_files.tar /path/to/my/directory
4 file compression utility to combine multiple files into a compressed archive file.

Ví dụ

  • Để sử dụng
    tar -cvf my_files.tar /path/to/my/directory
    
    2 và
    tar -cvf my_files.tar /path/to/my/directory
    
    4 để kết hợp nhiều tệp thành một tệp lưu trữ nén [ví dụ:
    tar -cvzf my_files.tar.gz /path/to/my/directory
    
    4], hãy sử dụng lệnh sau [thay thế
    tar -cvf my_files.tar /path/to/my/directory
    
    7 và
    tar -cvf my_files.tar /path/to/my/directory
    
    8 bằng tên của các tệp bạn muốn kết hợp].
    tar -cvzf my_files.tar.gz file1 file2
    
  • Để sử dụng
    tar -cvf my_files.tar /path/to/my/directory
    
    2 và
    tar -cvf my_files.tar /path/to/my/directory
    
    4 để kết hợp tất cả các tệp trong một thư mục thành một tệp lưu trữ nén [ví dụ:
    tar -cvzf my_files.tar.gz /path/to/my/directory
    
    4], hãy sử dụng lệnh sau [thay thế
    tar -cvzf my_files.tar.gz file1 file2
    
    0 bằng đường dẫn tuyệt đối đến thư mục chứa các tệp bạn muốn kết hợp].
    tar -cvzf my_files.tar.gz /path/to/my/directory
    

Ghi chú

  • Trong các ví dụ trên, tùy chọn
    tar -cvf - file1 file2 | gzip > my_files.tar.gz
    
    1 yêu cầu
    tar -cvf my_files.tar /path/to/my/directory
    
    2 sử dụng
    tar -cvf my_files.tar /path/to/my/directory
    
    4 để nén kho lưu trữ khi nó được tạo
  • Phần mở rộng tệp
    tar -cvf - file1 file2 | gzip > my_files.tar.gz
    
    4 và
    tar -cvf - file1 file2 | gzip > my_files.tar.gz
    
    5 là tương đương nhau;

Nếu hệ thống của bạn không sử dụng GNU

tar -cvf my_files.tar /path/to/my/directory
2, nhưng vẫn có
tar -cvf my_files.tar /path/to/my/directory
4, bạn có thể tạo một tệp lưu trữ
tar -cvf my_files.tar /path/to/my/directory
2 được nén [ví dụ:
tar -cvzf my_files.tar.gz /path/to/my/directory
4 bằng lệnh sau [thay thế
tar -cvf my_files.tar /path/to/my/directory
7 và
tar -cvf my_files.tar /path/to/my/directory
8 bằng tên của các tệp bạn muốn kết hợp]

tar -cvf - file1 file2 | gzip > my_files.tar.gz

Nếu

tar -cvf my_files.tar /path/to/my/directory
4 không có sẵn trên hệ thống của bạn, bạn có thể sử dụng tiện ích
tar -cvf my_files.tar /path/to/my/directory
5 để tạo một kho lưu trữ nén [ví dụ:
tar -cvf - file1 file2 | compress > my_files.tar.Z
6];

tar -cvf - file1 file2 | compress > my_files.tar.Z

Trích xuất nội dung của một tệp lưu trữ

Để trích xuất nội dung của tệp lưu trữ

tar -cvf my_files.tar /path/to/my/directory
2 được tạo bởi
tar -cvf my_files.tar /path/to/my/directory
2 [ví dụ:
tar -cvf my_files.tar /path/to/my/directory
6], hãy sử dụng lệnh sau

tar -xvf my_files.tar

Để trích xuất nội dung của tệp lưu trữ

tar -cvf my_files.tar /path/to/my/directory
2 được nén bằng
tar -cvf my_files.tar /path/to/my/directory
4 [ví dụ:
tar -cvzf my_files.tar.gz /path/to/my/directory
4], hãy sử dụng lệnh sau

tar -xvzf my_files.tar.gz

Nếu bạn không sử dụng GNU

tar -cvf my_files.tar /path/to/my/directory
2 và cần trích xuất nội dung của tệp lưu trữ
tar -cvf my_files.tar /path/to/my/directory
2 được nén bằng
tar -cvf my_files.tar /path/to/my/directory
4 [ví dụ:
tar -cvzf my_files.tar.gz /path/to/my/directory
4], hãy sử dụng lệnh sau

gunzip -c my_files.tar.gz | tar -xvf -

Để trích xuất nội dung của tệp lưu trữ

tar -cvf my_files.tar /path/to/my/directory
2 được nén bằng
tar -cvf my_files.tar /path/to/my/directory
5 [ví dụ:
tar -cvf - file1 file2 | compress > my_files.tar.Z
6], hãy sử dụng lệnh sau

uncompress -c my_files.tar.Z | tar -xvf -

Thông tin thêm

Khi sử dụng lệnh

tar -cvf my_files.tar /path/to/my/directory
2, thứ tự của các tùy chọn đôi khi có vấn đề. Ví dụ: một số phiên bản của
tar -cvf my_files.tar /path/to/my/directory
2 [không phải GNU
tar -cvf my_files.tar /path/to/my/directory
2] yêu cầu tùy chọn
tar -cvzf my_files.tar.gz file1 file2
3 ngay sau đó là khoảng trắng và tên của tệp lưu trữ
tar -cvf my_files.tar /path/to/my/directory
2

Lệnh

tar -cvf my_files.tar /path/to/my/directory
2 có sẵn nhiều tùy chọn. Để biết chi tiết, hãy tham khảo trang hướng dẫn
tar -cvf my_files.tar /path/to/my/directory
2;

tar -cvf my_files.tar /path/to/my/directory
0

GNU

tar -cvf my_files.tar /path/to/my/directory
2 đi kèm với tài liệu bổ sung, bao gồm hướng dẫn, có thể truy cập thông qua giao diện Thông tin GNU. Bạn có thể truy cập tài liệu này bằng cách nhập

tar -cvf my_files.tar /path/to/my/directory
1

Trong giao diện Thông tin, nhấn

gunzip -c my_files.tar.gz | tar -xvf -
0 [dấu chấm hỏi] để xem danh sách các lệnh

Tại Đại học Indiana, để được hỗ trợ hệ thống Linux hoặc Unix cá nhân hoặc bộ phận, hãy xem Nhận trợ giúp về Linux hoặc Unix tại IU

Tài liệu liên quan

Về. Phần mở rộng tệp Z Tận dụng tốt hơn không gian đĩa của bạn trong Unix Giới thiệu về tệp nén trong Unix Kết hợp nhiều tệp văn bản thành một tệp duy nhất trong Unix

Làm cách nào để di chuyển nhiều tệp trong các thư mục khác nhau cùng một lúc trong Linux?

Để di chuyển nhiều tệp bằng lệnh mv chuyển tên tệp hoặc mẫu theo sau là đích . Ví dụ sau giống như trên nhưng sử dụng khớp mẫu để di chuyển tất cả các tệp bằng. phần mở rộng txt.

Bạn có thể tạo đồng thời nhiều tệp bằng lệnh mkdir không?

lệnh mkdir trong Linux cho phép người dùng tạo thư mục [còn được gọi là thư mục trong một số hệ điều hành]. Lệnh này có thể tạo nhiều thư mục cùng lúc cũng như đặt quyền cho các thư mục.

Chủ Đề