shell - Bash Script - Compress multiple directories in one archive -
i made script while use zip compress several different user specified directories. way script did read directories config.txt , compress each 1 individually. happens that, uses, of these directories in same parent. instance, i'll have following directories in /users/username/ directory:
desktop documents pictures is there way combine these 3 in same archive?
for reference, here current script:
bkupdate="/users/michaelgarrison/backup/bkup_"$(date +%y)-$(date +%m)-$(date +%d) # create backup directory if not exist mkdir -p $bkupdate # file directories specified config="config.txt" while read source destination="/users/michaelgarrison/" output=$bkupdate"/backup_"$source"_"$(date +%y)-$(date +%m)-$(date +%d)".zip" (cd /users/michaelgarrison/; zip -r $output $source) done < $config
zip -r backup desktop/* documents/* pictures/*
that compress files under desktop, documents , pictures under file named backup.zip
the trick of sorts reading list config.txt file, presumably vertical list or array , making 1 long string.
Comments
Post a Comment