zip command in unix with wildcards - unix

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

Related

How to "source" (not run line by line) an R script from the Windows command line

I am creating an R script myscript.R which manipulates an excel file by means of XLConnectpackage.
The point is it refers to several external files: the excel file itself and another R file (functions library), so I need to set a working directory in the location of the script (so that relative paths to external files work properly).
I am using the following in my script
new_wd <- dirname(sys.frame(1)$ofile)
setwd(new_wd)
When I source the script from my RStudio it gets the job done. The problem is that the script is to be used by non-programmers, non-Rstutio-users, so I create .bat file (which I want to turn into an .exe one)
"C:\Program Files\R\R-4.0.3\bin\Rscript.exe" "C:\my\path\to\myscript.R"
It executes the script line by line but sys.frame(1) only works when sourcing.
How could I solve it?
Thanx
I have found a solution and it works properly.
From CMD command line or from a .bat file one can add an argument -e to the command, so that you can use a R language.
absolute\path\to\Rscript.exe -e "source('"relative\path\to\myscript.R"')"
It worked for me.
Besides, as Compo commented, I think there's no need for a .exe file, since a .bat does the job.

PuTTY Plink save files name to text file, and PSFTP only those

I am trying to take the files that I get with PuTTY's Plink command but save the file names to a text file so that I can only pull those files with PSFTP afterwards. Or can this be done without a temp text file?
The files I get are modified in the last 15 min, and I only want to get those files. I am new to PuTTY and FTP in general. I searched everywhere but cannot find anything that helps.
Any help is appreciated,
Thank you
You have to generate the PSFTP script file dynamically by reading the Plink output file line by line and producing a put command for each line.
See Batch files: How to read a file?
Or use an SFTP client that can directly download only files created in the last 15 minutes.
For example with WinSCP scripting:
winscp.com /command ^
"open sftp://username:password#example.com/ -hostkey=""fingerprint""" ^
"get /path/*>15N c:\path\" ^
"exit"
Read about file masks with a time constraint.
(I'm the author of WinSCP)

Need help extracting data from a corrupt file

I have a file located at the following location on my computer:
D:\Pictures\Imported Catalogue\Ojulari-2
I want to be able to extract the data from the (corrupt file) database file into a text file with all the SQL commands needed to recreate the database.
I'm following instructions from the following link, but I seem to be stuck executing the right command line or should I say navigation the the location of the corrupt file using the command line provided (See below)
Link to instructions I am following: http://gerhardstrasse.wordpress.com/2010/08/19/recover-from-a-corrupt-adobe-lightroom-catalog-file/
Command line I am trying to execute:
echo .dump | ./sqlite3 ~/lightroom_catalog.lrcat > ~/lightroom_catalog.sql
Download the sqlite3 command-line shell, and put the .exe file in the same directory as the database.
Open a Windows command-line shell, and go to that directory:
D:
cd "\Pictures\Imported Catalogue\Ojulari-2"
Execute:
sqlite3 MyDatabaseFile .dump > MyDatabase.sql

Unzipping Multiple zip files using 7zip command line

I have a number of zip files located in a single folder eg:
file1.gz
file2.gz
file3.gz
file4.gz
I'm looking for a way of automatically unzipping these using a batch job to a similarly named folder structure so for example the contents of file1.gz will drop into a folder named file1.
I have been told that 7zip would address my issue but can't figure out how to go about it.
Any help is greatly appreciated.
Which OS are you using? This is something you'd do using the shell's capabilities, you could write
for A in *.gz ; do gunzip $A ; done
I'm using gunzip here, because .gz is actually gzip, But you can use the 7zip CLI tool as well, of course. If you're on Windows, then I recommend installing a real shell (the standard cmd.exe can not really be considered a shell IMHO).

Creating Zip of directory in Unix m/c

on Unix m/c i have folder in which there are few more folders..
I wants to make zip file of parent folder. and i should able to unzip this zip file in windows m/c..
Can you please advice..
thanks in advance..
given that the program 'zip' is available, the following should work:
zip -r archive_name.zip folder
From midnight commander highlight the directory that you want to zip, then press F2 to get to the user menu, then # to perform an operation on it. You can now enter zip -r archive.zip followed by return, where archive.zip is that name of the zip file that you want to create.
zip -r parent-directory parent-directory
If you have zip installed on your Unix host.
It will create parent-directory.zip file and it can be unzipped on Windows using native unzip Windows program.

Resources