'bash'에 해당되는 글 2건

  1. 2012.03.08 라인 피드 문제
  2. 2009.03.24 bash와 csh의 차이점

라인 피드 문제

c or linux 2012. 3. 8. 19:09

.bashrc가 문제가 없는데, 계속 .bashrc를 못읽는다면. 파일 포맷을 의심한다.

-bash-3.00$ source .bashrc_backup
-bash: .bashrc_backup: line 7: syntax error: unexpected end of file


윈도우에서 커밋한 라인피드가 문제이다.
 
-bash-3.00$ file /home/www/work/.bashrc
/home/www/work/.bashrc: ASCII text, with CRLF line terminators



-bash-3.00$ perl -pi -e "s/\r//g" .bashrc
-bash-3.00$ file .bashrc
.bashrc: ASCII text
-bash-3.00$ source .bashrc


file /home/www/work/.bashrc
/home/www/work/.bashrc: ASCII text

잘 동작한다.

'c or linux' 카테고리의 다른 글

iproute2 (tc)  (0) 2012.03.12
struct 초기화 - memset  (0) 2012.03.12
리눅스 및 MMU 가상메모리 공부  (1) 2012.02.22
리눅스에서 디스크 용량 체크  (0) 2012.02.07
awk를 이해하는 데 도움이 되는 글들  (0) 2012.02.03
Posted by '김용환'
,

csh 스크립트를 정리하다가. 발견한 사실.. (이미 오래전에 적었을지도 모르지만.. ^^;;)

 

#!/bin/csh

 wget -O serverStatusLog 'http://127.0.0.1/server-status?auto';
cat serverStatusLog | awk -F: '{ print $2 }' > statusCurrent

set current=(`cat statusCurrent`)

 

csh에서의 ( ) 마크는 bash 에서는 다르게 해석한다고 말했는데..  

csh에서는 개행문자뿐 아니라 사이띄기도 ( )를 이용하면 배열로 만들 수 있는데 반해서

bash에서는 오직 개행문자만 배열로 만들 수 있다.

 

만약 개행문자로 나눌 수 있는 값이면, 아래처럼 그래도 쓸 수 있다.

 

#!/bin/csh

 wget -O serverStatusLog 'http://127.0.0.1/server-status?auto';
cat serverStatusLog | awk -F: '{ print $2 }' > nstatusCurrent

current=(`cat nstatusCurrent`)

 

그러나, 스페이로 이루어질 때는 tr을 이용해서 배열로 만들면 된다.

 

#!/bin/csh

 wget -O serverStatusLog 'http://127.0.0.1/server-status?auto';
cat serverStatusLog | awk -F: '{ print $2 }' > nstatusCurrent

current=`echo nstatusCurrent | tr ' ' ' '`

 

 

Posted by '김용환'
,