하나의 출력값을 다른 프로그램의 입력값으로 하고 싶습니다.
안녕하세요 ^^
몇일전에도 질문을 올려서 덕분에 도움을 많이 받았던 넘입니다.
이번에도 제가 잘 몰라서 이렇게 염치불구하고 올리게 되네요
kldp 하우투 문서를 봐도 제가 원하는것을 못찾아서 이렇게 올립니다.
http://doc.kldp.org/HOWTO/html/Adv-Bash-Scr-HOWTO/
혹시라도 제가 질문한 것이 위 문서에 있으면 좀 찾아주세요 ㅠㅠ
제가 질문하고자 하는것은
두개의 쉘 스크립트가 있는데 한개의 스크립트 실행 결과값을
다른 스크립트의 입력값으로 넣고 싶습니다.
밑에 예제를 보시면
#!/bin/bash # i or l substition! script i="[^a-km-z]" l="[^a-hj-z]" for input in $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} do if [ $input == i ] then echo -n "$i " elif [ $input == l ] then echo -n "$l " else echo -n "$input " fi done echo "" exit 0
사용자가 입력하는 값을 받아서 I 나 L 이 들어오면
치환을 해주는 것입니다.
h e l l o를 넣어주면
h e [^a-hj-z] [^a-hj-z] o
로 변환이 되어서 나옵니다.
h e [^a-hj-z] [^a-hj-z] o
이 출력값을 다른 스크립트의 입력값으로 하고 싶은데 생각보다 안되네요
저는 쉘상에서$ ./foo.bash h e l l o | ./too.bash #두 스크립트사이에 파이프
를 넣어서 했는데 파이프가 깨진다고 나옵니다.
물론 too.bash스크립트도 위 스크립트처럼 $1,$2.....${12}를 써서 처리를 하는 스크립트입니다.
제가 멍청해서 두개를 합치지 못하겠습니다. 합쳐도 결과값이 따로 나옵니다.
그래서 생각한게....두개 스크립트를 써서 한개의 출력값을 다른 스크립트의 입력값으로 하자입니다.
두번째 스크립트도 올릴테니 조언이라도 해주시면 감사하겠습니다. ㅠㅠ
#!/bin/bash # This is BAsh Script for Character Trick about wrod_not_word # written by n00b =) # last modified 20041220 # written by donedeckman =) a="[^a-z]" # regexp for wrod b="[^a-z]?" # regexp for wrod c="\\b" # regexp for wrod d="\\s" # regexp for wrod i="[^a-km-z]" # regexp for pass L l="[^a-hj-z]" # regexp for pass I filter=filter/wrod_not_word.txt # for saved Character trick file if [[ -f $filter ]] # must exist file! then : > $filter # initiate wrod file case $# in "13") echo "too many characters, allowd 3-12 characters only!" exit 1 ;; "12") echo "12 characters $1$2$3$4$5$6$7$8$9${10}${11}${12}" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$a$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$a$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$a$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b$a$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b$a$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$b$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$a$7$b$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$a$8$b$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$a$9$b${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$a${10}$b${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$a${11}$b${12}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$a${12}$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "11") echo "11 characters $1$2$3$4$5$6$7$8$9${10}${11}" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$b$7$b$8$b$8$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$a$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$a$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$a$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b$a$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$b$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$a$7$b$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$a$8$b$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$a$9$b${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$a${10}$b${11}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$a${11}$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "10") echo "10 characters $1$2$3$4$5$6$7$8$9${10}" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$a$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$a$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$a$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$b$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$a$7$b$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$a$8$b$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$a$9$b${10}$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$a${10}$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "9") echo "9 characters $1$2$3$4$5$6$7$8$9" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$a$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$a$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$b$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$a$7$b$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$a$8$b$9$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$8$a$9$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "8") echo "8 characters $1$2$3$4$5$6$7$8" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$a$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$b$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$a$7$b$8$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$7$a$8$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "7") echo "7 characters $1$2$3$4$5$6$7" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$b$7$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$6$a$7$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "6") echo "6 characters $1$2$3$4$5$6" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$b$6$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$b$6$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$b$6$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$b$6$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$b$6$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$b$6$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$b$6$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$b$6$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$b$6$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$5$a$6$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "5") echo "5 characters $1$2$3$4$5" >> $filter echo "$d$a$b$2$b$3$b$4$b$5$c" >> $filter echo "$c$1$b$a$b$3$b$4$b$5$c" >> $filter echo "$c$1$b$2$b$a$b$4$b$5$c" >> $filter echo "$c$1$b$2$b$3$b$a$b$5$c" >> $filter echo "$c$1$b$2$b$3$b$4$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$b$5$c" >> $filter echo "$c$1$b$2$a$3$b$4$b$5$c" >> $filter echo "$c$1$b$2$b$3$a$4$b$5$c" >> $filter echo "$c$1$b$2$b$3$b$4$a$5$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "4") echo "4 characters $1$2$3$4" >> $filter echo "$d$a$b$2$b$3$b$4$c" >> $filter echo "$c$1$b$a$b$3$b$4$c" >> $filter echo "$c$1$b$2$b$a$b$4$c" >> $filter echo "$c$1$b$2$b$3$b$a$d" >> $filter echo "$c$1$a$2$b$3$b$4$c" >> $filter echo "$c$1$b$2$a$3$b$4$c" >> $filter echo "$c$1$b$2$b$3$a$4$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; "3") echo "3 characters $1$2$3" >> $filter echo "$c$1$a$2$a$3$c" >> $filter wc $filter ; cat $filter ; exit 0 ;; *) echo "oops wrong character number" exit 1 ;; esac else echo "make a file first!" fi exit 0
너무 길어서 스크립트는 못봤는데요 ^^;;xargs를 써보세요.
너무 길어서 스크립트는 못봤는데요 ^^;;
xargs를 써보세요.
$ ./foo.bash h e l l o | xargs ./too.bash
헉 감사합니다. ㅠㅠ
촙5님 해봤는데 되네요 ㅠㅠ
몰랐던 명령어였습니다. xargs ㅠㅠ
이렇게 간단하다니 ... 멋지세요 >_</
감사드립니다. 덕분에 좋은 명령어도 알게 되었네요 ^^
전 다시 스크립트 짜러 -_ㅠ /
감사합니다. ^^
댓글 달기