0

我在fleetctl中有一个文件,我们称之为file@123.service 我有一个本地文件,我们称之为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
4

1 回答 1

0

解决方案:

找到了解决方案

DIFF=$(fleetctl cat $fleetctlFile | diff -q -w ~/$localServiceUnit -)

然后只需检查 $DIFF var

if [ -z "$DIFF" ]
then
  echo "No DIFF"
else
  echo "DIFF was found"
fi
于 2015-12-16T12:30:32.493 回答