티스토리 뷰

기타

unzip *.zip filename not matched

developer0hye 2024. 8. 10. 11:29

unzip *.zip

 

했을때 filename not matched 라는 caution 이 떠서 Claude 한테 물어보니, 아래 같이 하라고 Claude가 알려줬다. 나는 for zip in *.zip; do unzip "$zip"; done  로 해결했다.

 

 

The issue you're encountering is due to how the shell is interpreting the wildcard (*) in your unzip command. Let me explain what's happening:

  1. When you use unzip *.zip, the shell expands this wildcard before passing it to the unzip command.
  2. In this case, it's expanding to a list of all .zip files in alphabetical order.
  3. The unzip command is then trying to process this as: unzip xxxx-004.zip xxxx -005.zip ...
  4. Unzip is interpreting the first filename as the archive to extract, and all subsequent filenames as files to extract from within that archive.
  5. Since the other .zip files don't exist inside the first .zip file, you're getting those "filename not matched" messages.

To fix this and unzip all your files, you can use one of these methods:


  1. Use a for loop:
    Copy
    for zip in *.zip; do unzip "$zip"; done
  2. Use find with xargs:
    Copy
    find . -name "*.zip" -print0 | xargs -0 -I {} unzip '{}'
  3. If your version of unzip supports it, you can use the -q (quiet) option to suppress the warnings:
    Copy
    unzip -q "*.zip"

These methods will unzip all your .zip files in the current directory. Choose the one you're most comfortable with. The for loop is generally the most straightforward and widely compatible option.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함