I'm a newbie on Linux and had to do something like this with the zip command:
My folder structure inside a zip file abc.zip is:
-- currentdir
-- onestepdeep
-- abc.zip
-- folder1
-- textfile.txt
-- folder2
-- seconddir
-- folder3
-- textfile.txt
I need to copy the file textfile.txt
from the seconddir/folder3
into folder1
inside abc.zip
I could move textfile.txt
into abc.zip
with the following outcomes:
- It would move into
abc.zip
asfolder3/textfile.txt
(the hierarchy preserved) - Also used a
-j
switch (help said it junked the path info and it did but) – it would move only intoabc.zip
and sit at the same level asfolder1
andfolder2
instead of replacing thetextfile.txt
withinabc.zip/folder1
My question is – I want to replace the abc.zip/folder1/textfile.txt
with the one inside seconddir/folder3/textfile.txt
.
How do I achieve this via the command line interface?
Best Answer
I also use tar, but if you require zip then:
zip -b path/to/create/in zipfile.zip textfile.txt