after watching Uncle Psy"s linux cuisine, I wrote an identical script on the knowledge of learning service, but it didn"t work. Is this the wrong way to write it? The
process is as follows:
[root@localhost backups]-sharp ls
backup.log backup.sh backup.sh.bak backup-system-2019-02-12.tar.gz test.txt
[root@localhost backups]-sharp source= ". / {test.txt,backup.sh}"
[root@localhost backups]-sharp echo $source
. / {test.txt,backup.sh}
[root@localhost backups]-sharp cat $source
cat:. / {test.txt Backup.sh}: there is no file or directory
[root@localhost backups]-sharp cat. / {test.txt,backup.sh}
test
source= "/ etc / home / root / var/lib / var/spool/ {cron,at,mail}"
target= "/ backups/backup-system-$ (date +% Y-%m-%d) .tar.gz"
[!-d / backups] & & mkdir / backups
tar-zcvf ${target} ${source} & > / backups/backup.log
I found that running this cat $source didn"t produce the expected results. Really look for the existence of. / {test.txt,backup.sh}. The function of this usage has not been realized. But it"s normal to directly use cat. / {test.txt,backup.sh} to get the desired results.
source= ". / {test.txt,backup.sh}"
cat $source
cat. / {test.txt,backup.sh}
cat. / {test.txt,backup.sh} is not equivalent to cat $source