문제

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
도움이 되었습니까?

해결책

try curly bracket

tar -cvf gppbasic.$(date +%Y%m%d.%k%M).tar $x/*.{php,html,css,bmp}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top