- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道我听起来可能很奇怪,但我想知道我是否可以对某些文件执行 if [tar -xvf] 并返回 true 或 false 。
如果打包成功,我需要在文件中写入一些内容,如果不成功,则在同一文件中写入其他内容。
有点像
if[ find . -maxdepth 1 -name "*.tar" -exec tar -xvf {} ] ; then
echo " Untar Successful"> test.txt
else
echo "Untar Not Successful"> test.txt
如果我能做些什么来实现这个,请告诉我
最佳答案
EXIT STATUS
The tar utility exits 0 on success, and >0 if an error occurs.
你可以像这样检查错误
if [ $? -ne 0 ]; then
$在哪里?是最近的前台管道退出状态。
关于unix - 可以在 If 语句中使用 tar -xvf 返回 true 或 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6853022/
我正在使用以下命令在 Linux 服务器上提取一个 tar 文件 tar xvf httpd-2.2.31.tar tar -xvf httpd-2.2.31.tar 两者都具有相同的输出,这里的连字
我试图将 Java jar 文件提取为 java -xvf my.jar 但它抛出错误 Unrecognized option: -xvf Could not create the Java virt
我有一个下载版本 http://agentzh.org/misc/nginx/openresty-1.9.7.3.tar 。我将其重命名为 openresty-1.9.7.3.tar.gz。 我正在尝
我试图提取 test.jar命令正在成功执行但没有输出。 user@host:home/test->ll drwxr-xr-x 107 user abc 6040 Apr 4 09:55 .. d
我正在为 Ubuntu 开发一个 C++ 程序,该程序使用 curl_easy_perform 下载 tar 存档,在将存档下载到/tmp 后,我使用 popen 执行适当的 tar 命令行。 当我运
我知道我听起来可能很奇怪,但我想知道我是否可以对某些文件执行 if [tar -xvf] 并返回 true 或 false 。 如果打包成功,我需要在文件中写入一些内容,如果不成功,则在同一文件中写入
我有包含不同文件夹、子文件夹和文件的 jar。要列出和查看 jar 的内容,我可以使用 jar -tvf jar_name 。是否有任何方法 jar -tvf 或类似的其他命令将仅列出 jar 内容内
我正在尝试使用 Java 批处理应用程序在 Unix 计算机上解压文件。 源代码: String fileName = "x98_dms_12"; Runtime.getRuntime(
我使用命令 tar 一组文件:tar -czvf file.tar.gz file/ 然后复制到 USB(ext4 格式),我检查了我可以解压它。重装系统后,挂载usb时发生了一些错误,我执行fsck
我是一名优秀的程序员,十分优秀!