San*_*h S 3 shell command-line
我想下载一个文件,解压它并重命名该文件夹。
我可以下载该文件并将其解压
curl https://s3.amazonaws.com/sampletest/sample.tar.gz | tar xz
Run Code Online (Sandbox Code Playgroud)
如何在同一命令中重命名文件夹?
curl https://s3.amazonaws.com/sampletest/sample.tar.gz | tar xz | mv ???????
Run Code Online (Sandbox Code Playgroud)
我不想在命令中明确使用文件夹名称。
这是可能的,但并非微不足道。如果您的 tar (例如 GNU Tar)支持它,创建您自己的目录,cd 进入它,然后传递--strip-components 1或--strip-path 1到会更容易。tar
File name transformations:
--strip-components=NUMBER strip NUMBER leading components from file
names on extraction
--transform=EXPRESSION, --xform=EXPRESSION
use sed replace EXPRESSION to transform file names
Run Code Online (Sandbox Code Playgroud)