Ubuntu系统中7z命令参数失效问题求助
Let's break down exactly what's going wrong here—your installed p7zip version (9.20.1) is a pretty old release (from 2011), and it doesn't support some of the newer parameters you're trying to use. Here's the play-by-play:
1. The -og Parameter Problem
In older 7-Zip versions like 9.20.1, the -o (output directory) switch requires you to specify the full path immediately after it—there's no standalone -og option. If you're trying to extract files to a directory named g, you need to write it as -og/ (for an absolute path) or -o./g (for a relative path to your current working directory). Critical note: there's no space between -o and the path.
2. The -bsp2 Parameter Problem
The -bsp2 switch is a newer addition to 7-Zip. In version 9.20.1, the -bsp switch alone enables progress output to standard output—there's no support for the numeric suffix (2) to adjust output behavior. If you need to redirect error streams, you'll have to use shell-level redirection instead of a 7-Zip parameter.
Fixed Command Examples
Extract to a g directory and show progress:
7z x my.zip -o./g -bsp
Redirect error output to standard output (simulating -bsp2 behavior):
7z x my.zip -o./g -bsp 2>&1
Bonus: Upgrade p7zip for Newer Features
Since Ubuntu Xenial's repositories only host the old 9.20.1 version, if you want access to all modern 7-Zip features (like -og and -bsp2), you could manually download a newer p7zip package from a trusted source or build it from source. That said, the fixed commands above will work perfectly with your current installation.
内容的提问来源于stack exchange,提问作者chapani

