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

1. Prompt 확인
]$ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}[\u@\h \W]$

 

2. Prompt 변경
]$ vi ~/.bashrc

 

59 if [ "$color_prompt" = yes ]; then
60 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\]\$ '
61 else
62 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '을(를) PS1='${debian_chroot:+($debian_chroot)}[\u@\h \W]$ '(으)로 변경
64 fi
65 unset color_prompt force_color_prompt

'linux' 카테고리의 다른 글

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

# Ubuntu(우분투)에서 쉘스크립트(.sh)를 실행할 때 다음과 같은 오류 메시지가 발생한다.

[: Linux: unexpected operator

# 쉘스크립트를 실행할 때 sh 명령을 사용하는데 보통은 bash로 링크 걸려 있다. 그런데 우분투의 경우는 sh -> dash 로 링크가 걸려 있다.

 

# sh의 링크 상태를 확인 명령어

]$ ls -ahl /bin/sh

]$ /bin/sh -> dash

 

해결방법_01) bash로 쉘스크립트 실행

]$ bash script.sh

 

해결방법_02) shbash로 링크하여 sh실행

]$ sudo unlink /bin/sh

]$ sudo ln -s /bin/bash /bin/sh

]$ sh script.sh

 

# dash shell 참고

https://ko.wikipedia.org/wiki/%EC%95%94%ED%82%A4%EC%8A%A4%ED%8A%B8_%EC%85%B8

▶ 최종해결방법) 스크립트(.sh)파일의 첫번째 줄에 #!/bin/bash 으로 변경(추가)하면 됨 ◀

 

'linux' 카테고리의 다른 글

cross compiler 설치 후  (0) 2020.08.27
sudo 명령어 패스워드 없이 사용하기  (0) 2019.12.30
Linux 명령어 모음 ...ing  (0) 2019.10.16
자동 압축해제 스크립트  (0) 2019.06.19
[Ubuntu] ShellPrompt 변경  (0) 2019.06.07
Posted by afewgood
,