bash脚本 - "焦油CZF ..."命令忽略参数 [英] Bash script - "tar czf ..." command ignore parameters
本文介绍了bash脚本 - "焦油CZF ..."命令忽略参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我叫了一个简单的bash脚本 script.sh
I have a simple bash script called script.sh
!#/bin/bash
tar czf /var/log/apache2/Backup_$(date "+%d-%m-%Y").tar.gz /var/log/apache2/ --exclude='backup*' --exclude='Backup*'
当我在SSH-控制台RUND这一行,一切工作正常,但是当我运行在Linux控制台使用.sh脚本庆典./script.sh$c$c>
When I rund this line in SSH-Console, all works fine but when I run the .sh-script at linux console with bash ./script.sh
那么焦油CZF ...
命令的作品却忽略了--exclude参数
then the tar czf ...
command works but ignore the --exclude parameters
请告诉我错了吗?我不知道...:/
Whats wrong? I don't know... :/
推荐答案
试试这个:
更新
#!/bin/bash
tar -cZf /var/log/apache2/Backup_$(date +%Y%m%d).tgz.gz /var/log/apache2/ --exclude='backup*' --exclude='Backup*'
排除是一个模式?
看到这些帮助: help1 的help2 <一个href=\"http://stackoverflow.com/questions/10511406/tar-exclude-single-files-directories-not-patterns\">help3
这篇关于bash脚本 - &QUOT;焦油CZF ...&QUOT;命令忽略参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文