Depending on how a zip file is created, sometimes it will extract all of the files directly, and sometimes it will extract the files into a subdirectory.
If the latter is true, how can I force the unzip
command to "ignore" that first level directory?
Example:
cd /tmp
wget http://omeka.org/files/omeka-1.5.1.zip
mkdir omeka
unzip omeka-1.5.1.zip -d omeka/
cd omeka/
ll
What I'm getting is /tmp/omeka/omeka-1.5.1/
:
total 12
drwxr-xr-x 3 root root 4096 2012-05-08 18:44 ./
drwxrwxrwt 6 root root 4096 2012-05-08 18:44 ../
drwxr-xr-x 5 root root 4096 2012-04-20 14:54 omeka-1.5.1/
What I want is of the files extracted to /tmp/omeka/
, (one level up and no version number included in the directory structure)
/tmp/omeka/(files)
I know I can use the -j
option to "junk paths" but I want to keep the subdirectory structure, just not the top level directory structure. How can I do this?
mv
the files, but I wanted to see if there was a way to do this straight away from the unzip command/wordpress/
directory (no version number) inside the zip file. It is indeed fine tounzip
and thenmv
but having no control of this and having to do it in two steps has always gotten on my nerves a little. Fortunately Wordpress also comes in a.tar.gz
flavor :)cd /tmp/omeka && ln -s -T . omeka-1.5.1