I have a folder called newfast.zip in my remote server. I required to unzip as xyz folder. ( say xyz is my new folder name ), I tried like this:
[xxxxx#xxxxxautosuggest unzip]$ unzip newfast.zip xyz
Archive: newfast.zip
caution: filename not matched: xyz
[mohamear#stic-scm-autosuggest unzip]$ cl
But I turn with error. any one help me here please?
And any one suggest me the good tutorial page to learn all useful command of putty
Suggested work around: Create a directory, lets say zipcontent and then unzip the content into that dir: unzip file.zip -d zipcontent/
Suggested workaround: Unzip the folder to whatever it unzips to and rename it afterwards.
Related
Writing a beginner shell script and it's asking for to locate and verify if a file under a specific name is located within my home directory but I'm not sure what command would best fit that.
To find any file in linux, use this command:
find . -name file_name
point means current directory
you can change it to /home/
thanks
I have a logs file at directory cd /opt/app/logs named as
coa.log.1
uoa.log.2
erete-rere.log.1
now my concern is that i am looking for unix command which will zip the files having extension log.1 or log.2 or having log. extension anything
request you to please advise the unix comand to zip these files
Folks please advise for this
You can compress in a lot of formats in unix. The most commom is the tar.gz extension. If you are looking fot .zip specifically, there is a zip command: zip <zipname> <files>
To pass the file list you may use the * wirldcard, indicating any name. For example: *.log.*, as sugested by glen, will match every file that contains .log. in its name.
You probably want something like this:
zip backup_logs.zip /opt/app/logs/*.log.*
This will zip all files in the folder that matched what you asked and create a zip file in your current directory.
In R, if I use the command
write.csv(res,"~/table1_n500.csv")
, then the result is saved in C:\Users\John Smith\Documents.
But I expected it to be saved in C:\Users\John Smith\.
Can I change this home directory (referred by ~ mark) to C:\Users\John Smith\?
From my personal experience, i usually import data from a file (for example in the directory C:\Users\John Smith\DATA)
then i will set working directory as
setwd("C:/Users/John Smith/DATA")
While i want to save the output file in other directory like "C:\Users\John Smith" but not in the data folder.
so i will set relative working directory like
setwd("../")
And when you type getwd()
you will get [1] "C:/Users/John Smith"
Wish this help.
There are two ways to deal with this problem.
1.) Use the function setwd() to set the working directory (or home directory). All save and read commands will look for files in that working directory. I use this only sparingly, and for quick tiny project.
2.) A more preferred approach is to define a variable like dataInputDir, and use function file.path(dataInputDir, <your filename>) to generate a file path. The advantage is that if you are reading (writing) data from (to) multiple directories, you can do this more efficiently:
file.path(dataInputDir1, <your file or dir name>)
file.path(dataInputDir2, <your file or dir name>)
file.path(dataOutputDir1, <your file or dir name>)
file.path(dataOutputDir2, <your file or dir name>)
This approach is really handy for large complicated projects, and is highly recommended.
This is also helpful, if your program is to be executed on multiple platform like Windows, Mac, Linux. You'll have to change the directory location only at one place, and everything else will work smoothly.
Additionally, following functions/handles will be useful for dealing with directory names:
Quick fix:
setwd("../") # setwd to parent folder of current working directory (getwd())
More robust:
setwd(dirname(dataInputDir)) # Setwd to parent folder of dataInputDir
When I do something like this:
cvs -z3 -d :pserver:anoncvs#sourceware.org:/cvs/src co gdb
... cvs creates a directory 'src' at the path where it is called from, and checks out all the files from cvs/src in there..
In svn, you can do something like (pseudocode)
svn co http://.../TheProject LocalProjectName
... in which case, svn creates a directory 'LocalProjectName' at the path where it is called from, and checks out all the files from .../TheProject in there..
Is there a similar option for cvs (so that the top-level local directory has a different name from that in the repository?)
Thanks in advance for any answers,
Cheers!
cvs co -d LocalProjectName TheProject
This will check out a repository named TheProject into a directory named LocalProjectName.
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.