Question

Okay, this should be easy but I tried braces and brackets to get this to work but it has been too long since I did UNIX shell scripting.

I want to do quick backups using TAR of just selected files in a few directories, only those with PHP, HTML, CSS, or BMP extensions. Who has the fix?

#!/bin/bash

cd ~ ; x="public_html/gpp"

targpp="tar -cvf gppbasic.`date +%Y%m%d.%k%M`.tar $x/*.[php|html|css|bmp]"

$targpp  ;  ls -l gppbasic*.tar
Was it helpful?

Solution

try curly bracket

tar -cvf gppbasic.$(date +%Y%m%d.%k%M).tar $x/*.{php,html,css,bmp}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top