Zip all files in directory?

tkbx

Is there a way to zip all files in a given directory with the zip command? I've heard of using *.*, but I want it to work for extensionless files, too.

derobert

You can just use *; there is no need for *.*. File extensions are not special on Unix. * matches zero or more characters—including a dot. So it matches foo.png, because that's zero or more characters (seven, to be exact).

Note that * by default doesn't match files beginning with a dot (neither does *.*). This is often what you want. If not, in bash, if you shopt -s dotglob it will (but will still exclude . and ..). Other shells have different ways (or none at all) of including dotfiles.

Alternatively, zip also has a -r (recursive) option to do entire directory trees at once (and not have to worry about the dotfile problem):

zip -r myfiles.zip mydir

where mydir is the directory containing your files. Note that the produced zip will contain the directory structure as well as the files. As peterph points out in his comment, this is usually seen as a good thing: extracting the zip will neatly store all the extracted files in one subdirectory.

You can also tell zip to not store the paths with the -j/--junk-paths option.

The zip command comes with documentation telling you about all of its (many) options; type man zip to see that documentation. This isn't unique to zip; you can get documentation for most commands this way.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Python: zip all folders in directory

分類Dev

Php zip files without directory tree

分類Dev

Reading all files from a directory

分類Dev

Apply command to all files in a directory

分類Dev

list.files() all files in directory and subdirectories

分類Dev

Is that possible to integrate zip and tar.gz files as directory into the file system

分類Dev

Is that possible to integrate zip and tar.gz files as directory into the file system

分類Dev

PHP include file to all directory files by default

分類Dev

Iterate all files in a directory using a 'for' loop

分類Dev

Plot all files in a directory simultanously with gnuplot?

分類Dev

Python - Renaming all files in a directory using a loop

分類Dev

Find all files named *.txt in directory

分類Dev

C++ comparing all files in a directory with ::filesystem

分類Dev

Add all bib files from a directory to bookdown

分類Dev

View all files in a website's directory?

分類Dev

List of recently changed files for a directory and all subdirectories

分類Dev

Delete all files with executable permission in a directory

分類Dev

How to move all files from current directory to upper directory?

分類Dev

Shell Script for Delete all files in directory and print count of deleted files

分類Dev

How do I remove all files from wtihin a certain directory except for a child directory of that directory?

分類Dev

Recursively apply the msgfmt command to all .po files in directory with find -exec

分類Dev

Find and replace string in all Excel files workbook in a directory

分類Dev

Search all docx files with python-docx in a directory (batch)

分類Dev

How to get all files from a directory in Azure BLOB

分類Dev

Extract string between two keywords for all files in a directory

分類Dev

Swift delete all files from particular Document Directory Location

分類Dev

C++ Delete all files and subfolders but keep the directory itself

分類Dev

UNIX: How to change all hidden folders/files to visible in a directory

分類Dev

How can I exclude all subdirectories but include files of a directory in rsync?

Related 関連記事

  1. 1

    Python: zip all folders in directory

  2. 2

    Php zip files without directory tree

  3. 3

    Reading all files from a directory

  4. 4

    Apply command to all files in a directory

  5. 5

    list.files() all files in directory and subdirectories

  6. 6

    Is that possible to integrate zip and tar.gz files as directory into the file system

  7. 7

    Is that possible to integrate zip and tar.gz files as directory into the file system

  8. 8

    PHP include file to all directory files by default

  9. 9

    Iterate all files in a directory using a 'for' loop

  10. 10

    Plot all files in a directory simultanously with gnuplot?

  11. 11

    Python - Renaming all files in a directory using a loop

  12. 12

    Find all files named *.txt in directory

  13. 13

    C++ comparing all files in a directory with ::filesystem

  14. 14

    Add all bib files from a directory to bookdown

  15. 15

    View all files in a website's directory?

  16. 16

    List of recently changed files for a directory and all subdirectories

  17. 17

    Delete all files with executable permission in a directory

  18. 18

    How to move all files from current directory to upper directory?

  19. 19

    Shell Script for Delete all files in directory and print count of deleted files

  20. 20

    How do I remove all files from wtihin a certain directory except for a child directory of that directory?

  21. 21

    Recursively apply the msgfmt command to all .po files in directory with find -exec

  22. 22

    Find and replace string in all Excel files workbook in a directory

  23. 23

    Search all docx files with python-docx in a directory (batch)

  24. 24

    How to get all files from a directory in Azure BLOB

  25. 25

    Extract string between two keywords for all files in a directory

  26. 26

    Swift delete all files from particular Document Directory Location

  27. 27

    C++ Delete all files and subfolders but keep the directory itself

  28. 28

    UNIX: How to change all hidden folders/files to visible in a directory

  29. 29

    How can I exclude all subdirectories but include files of a directory in rsync?

ホットタグ

アーカイブ