Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Unzip subfolder to some path. Post 302369708 by mrwatkin on Monday 9th of November 2009 10:19:17 AM
Old 11-09-2009
Unzip subfolder to some path.

I have a zip file (somezipfile.zip) with the following contents in it:

dir1/subdir1/somefile1.txt
dir1/subdir2/somefile2.txt
dir1/subdir2/somefile3.txt
dir1/somefile3.txt
dir1/somefile4.txt
dir2/somefile5.txt
dir2/somefile6.txt

Lets say I unzip this to my home directory so now I have:

/home/me/dir1/subdir1/somefile1.txt
/home/me/dir1/subdir2/somefile2.txt
/home/me/dir1/subdir2/somefile3.txt
/home/me/dir1/somefile3.txt
/home/me/dir1/somefile4.txt
/home/me/dir2/somefile5.txt
/home/me/dir2/somefile6.txt

Now I do rm -rf /home/me/dir1/subdir2:
/home/me/dir1/subdir1/somefile1.txt
/home/me/dir1/somefile3.txt
/home/me/dir1/somefile4.txt
/home/me/dir2/somefile5.txt
/home/me/dir2/somefile6.txt

How can I unzip ONLY the subdir2 folder and the files it contains into the /home/me/dir1 folder without freshening or touching the other directories?

Also consider I may have subdirectories within subdir2 as well.

All responses are greatly appreciated. Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

2. Shell Programming and Scripting

Get zip path from unzip -l

I am listing the contents of a zip file and then grepping for a specific string ie: filename.a to get a line like: 309753 10-18-08 15:20 etc/filename.a The etc/filename.a is the path the file is at within the zip file...how might I capture this path as I want to use that path to unzip that... (2 Replies)
Discussion started by: phreezr
2 Replies

3. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

4. Shell Programming and Scripting

unzip few files but with same path and file name.

Hi Everyone, For exmaple, i have 5 .zip files. So i can do "unzip -L -o file1.zip -d /home/user1" for every 5 files. But the problem is those 5 zip files, have same path and file name. So if i use "-o", all will be overwirte. The output is unzip all files, but put all unzipped files... (1 Reply)
Discussion started by: jimmy_y
1 Replies

5. UNIX and Linux Applications

Samba read only subfolder.

Hi, I need to make a folder read only under a fileshare that has full permissions granted to it. The fileshare with full permissions is /u02/prodfileshare. The folder I need to make read only for everyone except the owner of the folder is called /u02/prodfileshare/EFT/purchases. ... (0 Replies)
Discussion started by: sparcman
0 Replies

6. UNIX for Dummies Questions & Answers

How to Get the count fo files in each subfolder

Hi is there a command to get the count of files inside each sub directory in a directory. example: in a directory like this /opt/:> ls subdir1 subdir2 subdir3 I need to see the count of files in sub directories like this: /opt/subdir1: 3 files /opt/subdir2: 5 files /opt/subdir3: 10... (1 Reply)
Discussion started by: sanjangr
1 Replies

7. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

8. Shell Programming and Scripting

Link multiple files from different subfolder to a new subfolder

Hi, I have the following subfolder with files: /data/a/1/xxx.txt /data/b/2/yyy.txt /data/c/3/zzz.txt And i have a set of new folders which have exactly the same structure as above but different disk without the files: /data_02/a/1/ /data_02/b/2/ /data_02/c/3/ Now i would like to... (6 Replies)
Discussion started by: total_ysf
6 Replies

9. UNIX for Dummies Questions & Answers

Unzip & Env Path Name

I need to download team foundation server on Unix (4 simple instructions below), but I am stuck.. I am newbie Unix user, so please be patient. -cd /home/Myname/Downloads, Unzip -Unzipped to /home/Myname/DestFolder -cd DestFolder, type tf -help, works there - outside this folder, doesn't... (1 Reply)
Discussion started by: software2007
1 Replies

10. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies
DirCompare(3pm) 					User Contributed Perl Documentation					   DirCompare(3pm)

NAME
File::DirCompare - Perl module to compare two directories using callbacks. SYNOPSIS
use File::DirCompare; # Simple diff -r --brief replacement use File::Basename; File::DirCompare->compare($dir1, $dir2, sub { my ($a, $b) = @_; if (! $b) { printf "Only in %s: %s ", dirname($a), basename($a); } elsif (! $a) { printf "Only in %s: %s ", dirname($b), basename($b); } else { print "Files $a and $b differ "; } }); # Version-control like Deleted/Added/Modified listing my (@listing, @modified); # use closure to collect results File::DirCompare->compare('old_tree', 'new_tree', sub { my ($a, $b) = @_; if (! $b) { push @listing, "D $a"; } elsif (! $a) { push @listing, "A $b"; } else { if (-f $a && -f $b) { push @listing, "M $b"; push @modified, $b; } else { # One file, one directory - treat as delete + add push @listing, "D $a"; push @listing, "A $b"; } } }); DESCRIPTION
File::DirCompare is a perl module to compare two directories using a callback, invoked for all files that are 'different' between the two directories, and for any files that exist only in one or other directory ('unique' files). File::DirCompare has a single public compare() method, with the following signature: File::DirCompare->compare($dir1, $dir2, $sub, $opts); The first three arguments are required - $dir1 and $dir2 are paths to the two directories to be compared, and $sub is the subroutine reference called for all unique or different files. $opts is an optional hashref of options - see OPTIONS below. The provided subroutine is called for all unique files, and for every pair of 'different' files encountered, with the following signature: $sub->($file1, $file2) where $file1 and $file2 are the paths to the two files. For 'unique' files i.e. where a file exists in only one directory, the subroutine is called with the other argument 'undef' i.e. for: $sub->($file1, undef) $sub->(undef, $file2) the first indicates $file1 exists only in the first directory given ($dir1), and the second indicates $file2 exists only in the second directory given ($dir2). OPTIONS The following optional arguments are supported, passed in using a hash reference after the three required arguments to compare() e.g. File::DirCompare->compare($dir1, $dir2, $sub, { cmp => $cmp_sub, ignore_unique => 1, }); cmp By default, two files are regarded as different if their contents do not match (tested with File::Compare::compare). That default behaviour can be overridden by providing a 'cmp' subroutine to do the file comparison, returning zero if the two files are equal, and non-zero if not. E.g. to compare using modification times instead of file contents: File::DirCompare->compare($dir1, $dir2, $sub, { cmp => sub { -M $_[0] <=> -M $_[1] }, }); ignore_cmp If you want to see all corresponding files, not just 'different' ones, set the 'ignore_cmp' flag to tell File::DirCompare to skip its file comparison checks i.e. File::DirCompare->compare($dir1, $dir2, $sub, { ignore_cmp => 1 }); ignore_unique If you want to ignore files that only exist in one of the two directories, set the 'ignore_unique' flag i.e. File::DirCompare->compare($dir1, $dir2, $sub, { ignore_unique => 1 }); SEE ALSO
File::Dircmp, which provides similar functionality (and whose directory walking code I've adapted for this module), but a simpler reporting-only interface, something like the first example in the SYNOPSIS above. AUTHOR AND CREDITS
Gavin Carr <gavin@openfusion.com.au> Thanks to Robin Barker for a bug report and fix for glob problems with whitespace. COPYRIGHT AND LICENSE
Copyright 2006-2007 by Gavin Carr. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-03-02 DirCompare(3pm)
All times are GMT -4. The time now is 07:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy