'tar'에 해당되는 글 1건

  1. 2019.06.19 자동 압축해제 스크립트

#!/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__

'linux' 카테고리의 다른 글

cross compiler 설치 후  (0) 2020.08.27
sudo 명령어 패스워드 없이 사용하기  (0) 2019.12.30
Linux 명령어 모음 ...ing  (0) 2019.10.16
[Ubuntu] ShellPrompt 변경  (0) 2019.06.07
[Ubuntu] unexpected operator 쉘스크립트 에러  (0) 2019.06.05
Posted by afewgood
,