Use the -o (overwrite) flag in the unzip command to overwrite the original file. The syntax is: unzip -o [-d directory] compressed file.zip. For example, unzip -o -d /tmp example.zip will unzip example.zip to the /tmp directory, overwriting the file with the same name.
How to use the unzip command in Linux to unzip a ZIP file to a specified directory and overwrite the original file
Direct answer:
Use the -o
(overwrite) flag in the unzip command to overwrite the original file.
Detailed explanation:
unzip is a Linux command used to decompress ZIP archives. By default, the unzip command will unzip files into the current working directory. To extract files to a specified directory, use the -d
(directory) flag.
Syntax:
<code>unzip -o [-d 目录] 压缩文件.zip</code>
Example:
The following command will extract the example.zip
file to /tmp
directory, overwriting any existing files with the same name in that directory:
<code>unzip -o -d /tmp example.zip</code>
Note:
- The o
flag will overwrite existing files with the same name, regardless of their type or content. -n
(non-overwrite) flag to extract only to files that do not conflict with existing files. The above is the detailed content of What should I do if the Linux decompression zip command goes to the specified directory and overwrites the original files?. For more information, please follow other related articles on the PHP Chinese website!