我目前正试图在中运行以下命令:
curl https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.65/bin/apache-tomcat-8.5.65.tar.gz | tar xvz --strip-components=1 - -C ~/tomcat-8.6.65当我运行这个命令时,它尝试解压缩默认值\\.\tape0,而不是tarball。我知道解决方法是用-f指定一个文件名,但是当我从URI中提取文件时,我不知道这是怎么可能的。有人有办法让这个命令正常工作吗?
发布于 2021-06-29 17:05:02
curl是Invoke-WebRequest cmdlet的内置别名;要调用外部curl.exe程序,请使用curl.exe,即包含文件扩展名.。
由于您确实需要原始字节流处理,所以使用PowerShell管道不是一个选项,但可以委托给cmd.exe。
# Make sure that the target dir. exists and get its full path.
# (If the target dir. doesn't exist, tar's -C option will fail.)
$targetDir = (New-Item -Force -ErrorAction Stop -Type Directory $HOME/tomcat-8.6.65).FullName
# Invoke cmd.exe's binary pipeline, passing the target dir.
# As an aside: tar.exe on Windows does NOT know that ~ refers to the 
#              user's home dir.
cmd /c @"
curl https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.65/bin/apache-tomcat-8.5.65.tar.gz | tar xvz --strip-components=1 -f - -C "$targetDir"
"@上面的内容还纠正了tar命令的语法问题:-应该是-f -。
https://stackoverflow.com/questions/68182870
复制相似问题