문자열이 다음과 같은 a.txt 파일이 있습니다. a a
cat a.txt하면
a a
이렇게 나오는데요
쉘에서
test=`cat a.txt` echo $test
이렇게 한 후 실행하면
aa
공백이 표시가 되지 않습니다.
제가 원하는것은 공백을 표현하고 싶은데 어떻게 하는지 고수님들 알려주세요^^
bash
[bushi@rose net]$ cat a.txt a a [bushi@rose net]$ [bushi@rose net]$ OLD_IFS=${IFS} [bushi@rose net]$ _test=$(cat a.txt) [bushi@rose net]$ IFS=${OLD_IFS} [bushi@rose net]$ echo ${_test} a a [bushi@rose net]$
OTL
안되네요''; 쉘 맨위에 설정하는 부분이 #!/usr/bin/ksh <-- 이거거든요
그럴리가요. ksh 도 bash 와 마찬가지로 sh 호환인데요.
쉘로 실행 안하고 bushi님께서 말씀하신대로 그냥 명령창에서만 실행해봤는데요
되지 않습니다 ㅠㅠ
a.txt은 a 와 a사이에 한 10줄정도 공백을 넣어놨고
중간과정 지나서 마지막 echo 했는데 a와 a사이에 공백 한개만 있을뿐 10개 그대로의 출력이 안됩니다
제가 뭐 확인해야할 부분이 있나요?
죄송합니다. 여러가지가 문제가 많은 코드를 올려버렸었네요.
[bushi@rose net]$ OLD_IFS=${IFS} [bushi@rose net]$ IFS= [bushi@rose net]$ _test=$(cat a.txt) [bushi@rose net]$ echo ${_test} a a [bushi@rose net]$ IFS=${OLD_IFS} [bushi@rose net]$ echo ${_test} a a [bushi@rose net]$
[bushi@rose net]$ ksh $ _cat() { OLD_IFS=${IFS}; IFS=; while read line; do echo ${line}; done < ${1}; IFS=${OLD_IFS}; } $ _echo() { OLD_IFS=${IFS}; IFS=; eval echo \$${1}; IFS=${OLD_IFS}; } $ $ _test=$(_cat a.txt) $ _echo _test a a $ $ _echo _test | while read line; do echo ${line}; done a a $
bash [bushi@rose net]$ cat
bash
[bushi@rose net]$ cat a.txt a a [bushi@rose net]$ [bushi@rose net]$ OLD_IFS=${IFS} [bushi@rose net]$ _test=$(cat a.txt) [bushi@rose net]$ IFS=${OLD_IFS} [bushi@rose net]$ echo ${_test} a a [bushi@rose net]$OTL
안되네요''; 쉘
안되네요''; 쉘 맨위에 설정하는 부분이 #!/usr/bin/ksh <-- 이거거든요
그럴리가요. ksh 도
그럴리가요. ksh 도 bash 와 마찬가지로 sh 호환인데요.
OTL
쉘로 실행 안하고
쉘로 실행 안하고 bushi님께서 말씀하신대로 그냥 명령창에서만 실행해봤는데요
되지 않습니다 ㅠㅠ
a.txt은 a 와 a사이에 한 10줄정도 공백을 넣어놨고
중간과정 지나서 마지막 echo 했는데 a와 a사이에 공백 한개만 있을뿐 10개 그대로의 출력이 안됩니다
제가 뭐 확인해야할 부분이 있나요?
죄송합니다.
죄송합니다. 여러가지가 문제가 많은 코드를 올려버렸었네요.
[bushi@rose net]$ OLD_IFS=${IFS} [bushi@rose net]$ IFS= [bushi@rose net]$ _test=$(cat a.txt) [bushi@rose net]$ echo ${_test} a a [bushi@rose net]$ IFS=${OLD_IFS} [bushi@rose net]$ echo ${_test} a a [bushi@rose net]$OTL
[bushi@rose net]$ ksh $
[bushi@rose net]$ ksh $ _cat() { OLD_IFS=${IFS}; IFS=; while read line; do echo ${line}; done < ${1}; IFS=${OLD_IFS}; } $ _echo() { OLD_IFS=${IFS}; IFS=; eval echo \$${1}; IFS=${OLD_IFS}; } $ $ _test=$(_cat a.txt) $ _echo _test a a $ $ _echo _test | while read line; do echo ${line}; done a a $OTL