문장을 한 단어씩 분석해야하는 상황입니다.
read -n 옵션으로 하고있었는데, 문제가 생겨서 다른 방법을 찾고 있습니다.
쉘 프로그래밍에서도 포인터 개념을 적용할 수 있는지 궁금합니다.
awk 나 sed 를 이용해 보세요. awk 로 한 단어씩 읽으면 될 것 같군요.
단어 단위라면 awk 나 cut 으로 공백문자로 잘라도 되고.. 아래처럼 shift 로 밀어도 됩니다.
#!/bin/sh A="abc def ghi" set $A while [ -n "$1" ] do echo $1 shift 1 done exit 0;
한 문자씩 건너뛴다면 substring extraction 을 쓰면 될 것 같군요.
#!/bin/sh A="abcde" last_pos=`expr ${#A} - 1` for pos in `seq 0 ${last_pos}` do echo ${A:$pos:1} done exit 0;
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
두분 모두 감사합니다.
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
포인터 개념이 아니라
awk 나 sed 를 이용해 보세요. awk 로 한 단어씩 읽으면 될 것 같군요.
음..
단어 단위라면 awk 나 cut 으로 공백문자로 잘라도 되고..
아래처럼 shift 로 밀어도 됩니다.
한 문자씩 건너뛴다면 substring extraction 을 쓰면 될 것 같군요.
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
도움 많이 되었습니다
두분 모두 감사합니다.
댓글 달기