Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Suppose i have a zip file Old.zip , inside it are fileA and fileB. then i unzip them using: unzip Old.zip -d Old, then i will have a directory named Old, with fileA and fileB inside.
Now the Old.zip is gone, and i want to zip it again, but if i use: zip -r New.zip Old, the New.zip is different from Old.zip: inside it are not two files, but one directory!
Before: After: I want:
Old.zip--+ New.zip--+ New.zip--+
+--fileA +--Old--+ +--fileA
+--fileB +--fileA +--fileB
+--fileB
Any suggestions? How should i use zip command correctly to keep the structure? I will NOT go into Old folder and use zip New.zip fileA fileB and move it to the parent folder since i will write it in shell script.
Try passing the the -j (junk paths) option to zip:
$ zip -rj New.zip Old
That way, the files will be stored without their relative paths.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I use Cygwin, and I write commands. On my Desktop I have two folders, named folder1 and folder2. In folder1 there is a text file. I want to move the text file to folder2. But when I use the mv command it doesn't work. I get an error message "no such file or directory".
My question is: how can I move file.txt from folder1 to folder2?
My code is:
/cygdrive/c/Users/Maichel/Desktop/folder1
$ mv file.txt folder2/.
This also doesn't work:
/cygdrive/c/Users/Maichel/Desktop/folder1
$ mv Desktop/file.txt Desktop/folder2/.
I have one question more: How can I open Dreamweaver in Cygwin? If I use notepad file.txt then the file is opened in notepad. How do I do this with Dreamweaver?
You need to reference your paths properly. If your directory hierarchy looks like this:
Desktop/
- folder1/
- folder2/
Then from inside folder1, you need to navigate up one directory with .. to get to Desktop, then go back down into folder2:
/cygdrive/c/Users/Maichel/Desktop/folder1
$ mv file.txt ../folder2/
You can also use the absolute path:
/cygdrive/c/Users/Maichel/Desktop/folder1
$ mv file.txt /cygdrive/c/Users/Maichel/Desktop/folder2/
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using below command to get the detailed list of files in each archive in a particular directory. unzip -l ".zip". But the problem with this command is that it is enlisting all the files in the archive. I want to limit the number of files to be listed to 5 per archive.
I am using ssh. Thanks.:)
you can either use head or tail to limit the top n line or bottom n line
unzip -l a.zip | head -n 5
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
i'm trying to move folders to another folders using command line, with overwrite if already exists, but i got error "Is a directory" when using mv..
example:
mv src/test/ dest/
there are many files and folders on src/test/, there are also some files and some folders on dest/
and i want files and folders on dest/ replaced with files and folder from src/test/ if exists, example:
src/test/bla/boo replaces dest/bla/boo
src/test/bla/bla/boo replaces dest/bla/bla/boo
also, everytime one file transfer completed, that one file deleted from src/test/
and overall transfer progress bar would be fine..
what rsync flag should i use to make this happend?
The following command line should achieve what you want:
$ rsync -a --progress --remove-source-files src/test/ dest
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have a file that contain list of files I want to archive with tar.
Let's call it mylist.txt
It contains:
/path1/path2/file1.txt
/path1/path2/file3.txt
...
/path1/path2/file10.txt
What I want to do is to archive this file into a tarball but excluding /path1/path2/.
Currently by doing this:
tar -cvf allfiles.tar -T mylist.txt
preserves the path after unarchiving.
I tried this but won't work too:
tar -cvf -C /path1/path2 allfiles.tar -T mylist.txt
It archives all the files in /path1/path2 even those which are not in mylist.txt
Is there a way to do it?
In your "Extraction phase" you can use the strip-components flag like
tar xvf tarname.tar --strip-components=n
which will remove the first n leading components of the file name. Although if you have different file-path-components this will not work for all cases.
If you want to do it while archiving, only one thing comes to mind, and I will share
INPUT: list of files + full paths
1) for each line, split the path out of the filename
2) execute cd to that path and tar on that filename
3) repeat for each line
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I've got a bunch of tar and tar.gz files that I would like to unzip. Inside these files, most of them have the same folder structure zipped up inside (although with different files).
If I were to do this manually by right-clicking and selecting "Extract Here," it'd would create a new folder for me with the original file name and dump the files there.
However, when I do this via the command line, the behavior isn't always the same. Sometimes it'd create the desired new folder and other times it wouldn't, causing it to overwrite the extraction of others.
Using the -C option seems to require the folder already existing. How can I mimic the behavior of the manual "Extract Here" in the command line?
Thanks.
You could create a bash function like this;
function untarhere() {
(mkdir -P $1; cd $1; tar xzf $2)
}
and then call it like
untarhere /your/destination/directory /your/tar/file.tar