zip -r with ~/ partially replicated my system directory - macos

I am trying to zip my nw.js application into a zip file. So I run this:
"win.sh" 3L, 121C
cp ~/nout/package.nw ~/nout/win/QuantumPilotWin/package.nw
zip -r ~/nout/QuantumPilotWin.zip ~/nout/win/QuantumPilotWin
I expected the zip file to be of a single folder, that of QuantumPilotWin
instead I get this structure:
How do I zip without the full path?
EDIT:
Trying Joe's steps I got this in the unzipped folder:

Run the zip -r command when you are in ~/nout/win/, so:
cd ~/nout/win/
zip -r ~/nout/QuantumPilotWin.zip QuantumPilotWin

Related

Failed to copy list of files to another folder

I have a text file called "list.txt" that contain all the directories of the files that need to be copied to a new folder (dir_newfolder). I wrote the code like below:
for file in $(cat list.txt); do cp ${file} dir_newfolder; done
I got list of errors: cp:"file_name":No such file or directory. The file_names are the lines pulled out from the "list.txt". But when I copy each file_names from the error message and use cp to copy to the new folder. There is no error.
I am using mac os terminal.
Thanks in advance.
Copy a file or folder locally
In the Terminal app on your Mac, use the cp command to make a copy of a file.
For example, to copy a folder named Expenses in your Documents folder to another volume named Data:
% cp -R ~/Documents/Expenses /Volumes/Data/Expenses
The -R flag causes cp to copy the folder and its contents. Note that the folder name does not end with a slash, which would change how cp copies the folder.
in your case:
make sure you are providing correct path list.txt and the correct path for destiny folder, also i mentioned how to access file variable in double quotes , try this code it's working for me
for file in $(cat ~/Documents/list.txt); do cp "$file" ~/dir_newfolder; done

7z, how to unzip without __MACOSX folder in terminal

I try to unzip a file with using x to keep the folder structure inside. But it creates a __MACOSX folder which I do not wish to have
At my project directory, I tried
7z x -y ./app/resources/Docs.zip -o./app/resources/Docs -x "__MACOSX"
But I got an error:
Too short switch:
-x
Please advice how can I extract a zip file and keep its folder structure but without the __MACOSX folder?
You must put -x in quotes:
7z x -y ./app/resources/Docs.zip "-o./app/resources/Docs" "-x__MACOSX"

Name not matched in creating zip folder with bash

I'm trying to create a zip folder in a bash script that contains the current date (YYYY_MM_DD).
I have this code:
currentArchive=$(date '+%Y_%m_%d')
zip -r ./aktuell ./Archive/${currentArchive}-bkt
But when I run the script I get the following error:
zip warning: name not matched: ./Archive/2017_03_30-bkt
I want the folder "aktuell" as a zip folder named "2017_03_30-bkt.zip" in the folder "Archive". The current folder "aktuell" exists.
What am I doing wrong?
You have the source and destination directories backwards in your zip command. Also, make sure the destination directory exists before executing zip.
currentArchive=$(date '+%Y_%m_%d')
mkdir -p ./Archive/
zip -r ./Archive/${currentArchive}-bkt ./aktuell

Zip folder created by shell script not opening

I am using the below script to zip the folder and it contents :-
cd /home/fs/Inbnd/
pwd
tar -cvf Image_test_new.zip Image
chmod 777 *
chown fusionc:staff *
The file image.zip is getting created successfully. But the file is not opening and showing an error :
Is there an error in the ststement I am using to zip?
tar -cvf makes a tar ball, not a zip archive. You can verify this in Linux, before trying to open it in Windows.
touch not_going_to_be_a_zip
tar -cvf not_really_a.zip not_going_to_be_a_zip
unzip not_really_a.zip
Archive: not_really_a.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of not_really_a.zip or
not_really_a.zip.zip, and cannot find not_really_a.zip.ZIP, period.
The zip utility does a good job at making zip archives.
touch will_be_a_zip
zip i_am_a.zip will_be_a_zip Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
unzip -t i_am_a.zip
Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
Note: unzip -t will test the archive only, make sure its okay before trying it in Windows.
If you cannot use the standard approach like zip/unzip and if you have JDK installed on your machine then you can use the jar utility from JDK's bin folder.
To zip a file
jar cvf zip_file_name.zip image.jpg
The only overhead is that it will add a META-INF folder with a file named MANIFEST.MF in it, which you can delete after extracting the zip file.
Try to use zip command instead of tar command.

how to download a folder from bash?

I want to download a complete folder from a jenkins project containing many folder
I try with a wget and it works for only one file doing :
wget http://jenkinsmedia:XXXX/job/Lib//280/artifact/tool.rpm
but in the same place there is tool.rpm, there is a folder Test
I want to download the whole folder, is it possible? Or will I have to pick files one by one?
Try using wget -r http://jenkinsmedia:XXXX/job/Lib//280/artifact/
This will create a folder, in that folder it will have a folder job and so on..
use wget -nH --cut-dirs=4 -r http://jenkinsmedia:XXXX/job/Lib//280/artifact/ if you just want to have the folder with the documents

Resources