c shell script 를 작성할때 함수 만드는 방법좀 알려주세요.
글쓴이: chojg711 / 작성시간: 일, 2007/02/18 - 2:31오전
안녕하세요.
최근 csh을 사용하게 됐습니다.
shell script를 작성하는데
csh 에서는 사용자정의함수를 어떻게 만드는건가요???
제가 가지고 있는 책들은 너무 허접한 책들밖에 없어서요... 거기에 나오지도 않고...
이렇게 저렇게 해봐도 안되네요.
도와주십시오.
일단, 함수를 만드는 형식.
메인 script에서 함수로 변수를 넘겨주는 방법.
정의한 함수의 값을 return해서 메인 script로 넘겨주는 방법.
csh은 이런게 안되나요??? 그럴리는 없다고 생각합니다.
꼭 부탁드릴께요.. ㅠㅠ
Forums:
열심히 찾아보니... 없다네요.. ㅠㅠ
http://www.iu.hio.no/~mark/unix/unix.html
위사이트의 Sub-shells () 항목에 보니 다음과 같이 나와있네요.
이걸 참고해서 어떻게든 활용해 봐야겠어요.
The C-shell does not allow you to define subroutines or functions, but you can create a local shell, with its own private variables by enclosing commands in parentheses.
#!/bin/csh
cd /etc
( cd /usr/bin; ls * ) > myfile
pwd
This program changes the working directory to /etc and then executes a subshell which inside the brackets changes directory to /usr/bin and lists the files there. The output of this private shell are sent to a file `myfile'. At the end we print out the current working directory just to show that the `cd' command in brackets had no effect on the main program.
Normally both parentheses must be on the same line. If a subshell command line gets too long, so that the brackets are not on the same line, you have to use backslash characters to continue the lines,
( command \
command \
command \
)
댓글 달기