자동 압축해제 스크립트
#!/bin/sh
# ========================================================
# 1)파일 압축
# tar -jcvpf [압축파일명] [압축 대상]...
# [afewgood@localhost ~]$ tar -jcvpf afewgood.tar.bz2 afew good
# 2)자동 압축해제 파일 생성
# cat extract.sh [압축파일명] > afewgood.zip(bin)
# [afewgood@localhost ~]$ cat extract.sh afewgood.tar.bz2 > afewgood.zip(bin)
# 3)파일 권한설정
# chmod xxx afewgood.zip(bin)
# [afewgood@localhost ~]$ chmod a+x afewgood.zip(bin)
# 4)압축 해제 (원하는 위치에 이동 후)
# ./afewgood.zip(bin)
# [afewgood@localhost ~]$ ./afewgood.zip(bin) 또는 sh afewgood.zip(bin)
# ========================================================
echo -n "Start Extracting file into "
pwd
# searches for the line number where finish the script and start the tar.gz
SKIP=`/usr/bin/awk '/^__ARCHIVE_BELOW__/ { print NR + 1; exit 0; }' $0`
# remeber file name
THIS=`pwd`/$0
# take the tarfile and pipe it into tar (just tar, no gzip)
/usr/bin/tail -n +$SKIP $THIS | /bin/tar jxvpf - -C ./
# Any script here will happen after the tar file extrace.
sync
sync
sync
echo "Finished"
ls -al
exit 0
# NOTE: Don't place any newline characters after the last line below.
__ARCHIVE_BELOW__