zip -r 1.zip /home/username/the_folder
At here, when i unzip 1.zip
, it will create /home/username/the_folder
, from whichever folder i am unzipping from.
How do I zip, stating the full absolute paths, but make the zip only contain the folder structure starting at, in this case for instance, /home/username
?
That way I could be at whatever path i wanted, unzip and it would just create the_folder
, and not /home/username/the_folder
.
An absolute path is defined as the specifying the location of a file or directory from the root directory(/). In other words we can say absolute path is a complete path from start of actual filesystem from / directory.
Syntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.
A path is either relative or absolute. An absolute path always contains the root element and the complete directory list required to locate the file. For example, /home/sally/statusReport is an absolute path. All of the information needed to locate the file is contained in the path string.
The absolutePath function works by beginning at the starting folder and moving up one level for each "../" in the relative path. Then it concatenates the changed starting folder with the relative path to produce the equivalent absolute path.
Just use the -j
option, works on OSX
, I don't know about linux.
zip -j -r 1.zip /home/username/the_folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With