Unzip gives me file path for filename - unzip

When I run unzip dir.zip and ls -l the result,
I got:
widgets\Draw\setting\nls\et\strings.js
I expect:
widgets
The zip is generated on windows with nodejs.
Thanks

Related

How to get the deb package located directory in preinst

I am creating a .deb package that would run a shell script as preinst.
The shell script needs some input files, which would be available at where I have the .deb package, as below.
Package_located_directory $ >
mydebpackage.deb
inputfile1
inputfile2
I would just transfer all the files to the different machine at any location and install it with dpkg -i mydebpackage.deb
I tried using pwd in the preinst to get the current deb file located directory.
So, I can get the path of the inputfiles from the preinst script.
But if I run pwd from preinst , it is giving me / instead of the package located directory.
Also I tried passing pwd from the PIPE to achieve this, as below,
pwd | dpkg -i mydebpackage.deb
But I do not want to depend on the user input for the path.
Please guide me for getting the current deb package located directory path from inside of preinst script.
it's better to use postinst and modify the file on your system.
for example : Modify the file /etc/test/test.txt in postinst file

zip command in unix with wildcards

I am trying to zip file which is in the format of Amazon*.xls in unix and also remove the source file after compression.Below is the used command
zip -m Amazon`date +%Y-%m-%d:%H:%M:%S`.zip Amazon*.xls
For the above command i am getting below error
zip I/O error: No such file or directory
zip error: Could not create output file Amazon.zip
PS: GZIP is working fine. I need zip format files.
It is not the zip, it is how your shell deals with expanding/substituting variables. Two lines solution for bash
export mydate=`date +%Y-%m-%d:%H:%M:%S`
zip -m Amazon_$mydate.zip *matrix*
Execute by hand (few secs difference) or better put in a shell script myzipper.sh and just source it.
Use '-p' instead of '-m', if zip files are to be extracted on Windows OS.
export mydate=date +%Y-%m-%d:%H:%M:%S
zip -p Amazon_$mydate.zip matrix

How to extract a .tar.gz file on UNIX

I have a file (reviews_dataset.tar.gz) that contains many files which contains data. I am required to extract the files in this archive and then perform some basic commands on the file. So far I have created a directory named (CW) and found a command tar zxvf fileNameHere.tgz but when I run this it of course cannot find my file as I have not "downloaded it" into my directory yet? How do I get this file into my directory so that I can then extract it? Sorry if this is poorly worded I am extremely new to this.
You must either run the command from the directory your file exists in, or provide a relative or absolute path to the file. Let's do the latter:
cd /home/jsmith
mkdir cw
cd cw
tar zxvf /home/jsmith/Downloads/fileNameHere.tgz
You should use the command with the options preceded by dash like this:
tar -zxvf filename.tar.gz
If you want to specify the directory to save all the files use -C:
tar -zxf filename.tar.gz -C /root/Desktop/folder

Unzip file and give permissions (UNIX, Solaris)

How could we unzip file and give (rwx) permissions to files and directories inside .zip file in Solaris?
unzip -d
It should be done in one command.
Not first unzip and then chmod -R +rwx

store unix command error message into file

I want to store error of unix command into file.
Ex.
cd /test
/test: No such file or directory.
I want to store error "/test: No such file or directory." into file
Can you please help?
How about
cd /test 2> myFile.txt

Resources