WHEREIS

얼핏 보면 심볼릭 링크가 걸려, 동일한 파일로 생각할 수 있으나

 

[root@k8s-master ~]# ls -al /bin/bash
-rwxr-xr-x 1 root root 964600  8월  8  2019 /bin/bash

 

[root@k8s-master ~]# ls -al /bin/sh
lrwxrwxrwx 1 root root 4 11월 11 13:26 /bin/sh -> bash

 

 

아래와 같이 bash 이냐 sh 이냐에 따라 구동이 안 되는 문법이 있다.

 

 

[root@k8s-master ~]# cat test.sh  

#!/bin/sh

wc < <(echo bar;echo foo)

 

 

[root@k8s-master ~]# bash test.sh 
      2       2       8

 

[root@k8s-master ~]# sh test.sh 
test.sh: line 3: syntax error near unexpected token `<'
test.sh: line 3: `wc < <(echo bar;echo foo)'

 

sh 의 경우 posix 표준을 준수하여 그렇다고 하는데, 아래와 같이 set 옵션을 주어 제거하면 된다

아니면 #!/bin/bash 로 설정하는게 더 좋을 듯 하다..

 

#!/bin/sh
set +o posix
wc < <(echo bar;echo foo)

 

참고사이트 : 

https://askubuntu.com/questions/422492/why-script-with-bin-bash-is-working-with-bin-sh-not

https://askubuntu.com/questions/141928/what-is-the-difference-between-bin-sh-and-bin-bash

https://askubuntu.com/questions/678915/whats-the-difference-between-and-in-bash

이 글을 공유합시다

facebook twitter kakaoTalk kakaostory naver band
loading