我在fleetctl中有一个文件,我们将其命名为file @123。我还有一个本地文件,我们将其命名为file@.service。
我想看看它们是不是不同。如果它们不同,我将启动一个销毁和启动命令,但我找不到在它们之间进行比较的方法。
我所做的是构建一个脚本:
check_diff ()
{
# Check if local file is diff from fleetctl file "file@123.service"
# file@123.service is currently active in the fleetctl
# Looking for something like
diff (fleetctl list-units | grep $1 | head -n 1 | awk '{print $1}') $1.service
}
# Get local file names and push them to the function
for unit in $(ls -l | awk '{print $9}' | grep -e \.service); do
check_diff ${unit%.*} # Will result unit as "file@"
done发布于 2015-12-16 20:30:32
解决方案:
找到解决方案
DIFF=$(fleetctl cat $fleetctlFile | diff -q -w ~/$localServiceUnit -)然后只需检查$DIFF变量
if [ -z "$DIFF" ]
then
echo "No DIFF"
else
echo "DIFF was found"
fihttps://stackoverflow.com/questions/34270408
复制相似问题