我在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