Search code examples
shellgrepzipls

Find all files that weren't unzipped


I have a folder that contains several zipped folders, I tried to unzip them but some trowed errors but since there are a lot of folders I can't seem to find which ones were not unzipped, my folder looks like this:

drwxr-xr-x 2 bruno bruno     36864 abr  3 21:18 00059285000136
-rw-rw-r-- 1 bruno bruno   1618361 abr  3 19:55 00059285000136.zip
drwxr-xr-x 2 bruno bruno     12288 abr  3 21:18 00059289000114
-rw-rw-r-- 1 bruno bruno    483970 abr  3 19:55 00059289000114.zip
drwxr-xr-x 2 bruno bruno     12288 abr  3 21:18 00059292000138
-rw-rw-r-- 1 bruno bruno    494923 abr  3 19:55 00059292000138.zip
drwxr-xr-x 2 bruno bruno     20480 abr  3 21:18 00059563000155
-rw-rw-r-- 1 bruno bruno    890522 abr  3 19:55 00059563000155.zip
drwxr-xr-x 2 bruno bruno     73728 abr  3 21:18 00059564000108
-rw-rw-r-- 1 bruno bruno   3216973 abr  3 19:55 00059564000108.zip
drwxr-xr-x 2 bruno bruno     20480 abr  3 21:18 00067859000118
-rw-rw-r-- 1 bruno bruno    905108 abr  3 19:55 00067859000118.zip
drwxr-xr-x 2 bruno bruno     49152 abr  3 21:18 00067860000142
-rw-rw-r-- 1 bruno bruno   2130747 abr  3 19:55 00067860000142.zip
drwxr-xr-x 2 bruno bruno     20480 abr  3 21:18 00068070000181
-rw-rw-r-- 1 bruno bruno    750779 abr  3 19:55 00068070000181.zip
drwxr-xr-x 2 bruno bruno      4096 abr  3 21:18 00068071000126
-rw-rw-r-- 1 bruno bruno      8595 abr  3 19:55 00068071000126.zip
drwxr-xr-x 2 bruno bruno     12288 abr  3 21:18 00073134000132
-rw-rw-r-- 1 bruno bruno    347212 abr  3 19:55 00073134000132.zip
drwxr-xr-x 2 bruno bruno     20480 abr  3 21:18 00073135000187
-rw-rw-r-- 1 bruno bruno    779648 abr  3 19:55 00073135000187.zip
drwxr-xr-x 2 bruno bruno      4096 abr  3 21:18 00073136000121
-rw-rw-r-- 1 bruno bruno    226300 abr  3 19:55 00073136000121.zip
drwxr-xr-x 2 bruno bruno     12288 abr  3 21:18 00074485000168
-rw-rw-r-- 1 bruno bruno    496361 abr  3 19:55 00074485000168.zip
drwxr-xr-x 2 bruno bruno     20480 abr  3 21:18 00083506000101
-rw-rw-r-- 1 bruno bruno    741531 abr  3 19:55 00083506000101.zip
drwxr-xr-x 2 bruno bruno     12288 abr  3 21:18 00084530000165
-rw-rw-r-- 1 bruno bruno    479596 abr  3 19:55 00084530000165.zip
drwxr-xr-x 2 bruno bruno     12288 abr  3 21:18 00088714000101
-rw-rw-r-- 1 bruno bruno    462495 abr  3 19:55 00088714000101.zip
-rw-rw-r-- 1 bruno bruno    682841 abr  3 19:55 00109143000136.zip

Is there any command to find which ones aren't unzipped? All the unzipped folders and they zipped pair have the same name (except the .zip).


Solution

  • If I understand correctly, the question is how to report every file NAME.zip file for which NAME does not exist. This script will do that:

    #!/bin/sh
    
    for fn in *.zip; do
      # Remove the trailing ".zip".
      base=$(echo "$fn" | sed 's/\.zip$//')
    
      if [ ! -e "$base" ]; then
        # The corresponding name without ".zip" does not exist.
        echo "$fn"
      fi
    done
    

    Example run:

    $ ls
    1  1.zip  2  2.zip  3.zip  4.zip  5  5.zip  find-not-zipped.sh*
    
    $ ./find-not-zipped.sh
    3.zip
    4.zip