모든 .sh 파일을 찾아 복사합니다.스크립트 백업

모든 .sh 파일을 찾아 복사합니다.스크립트 백업

.shLinux 설치에서 생성한 모든 스크립트를 찾습니다 (필요한 경우 재귀적으로 검색 - 기존 백업 폴더 제외).

그런 다음 -scriptbackup이라는 폴더에 모두 복사하고 tar gzip 파일로 보관합니다.

답변1

이와 같은 것이 작동해야합니다

directory=$(date +%Y-%m-%d)-scriptbackup
#create if it doesn't exist
mkdir -p "$directory"
#find and copy
#replace "." with the directory
#where you want to search for the files,
#if it isn't the same as the current directory
find . -name '*.sh' -exec cp '{}' "$directory" ';'
tar -cvzf "${directory}.tar.gz" "$directory"

관련 정보