셸 스 크 립 트 echo 출력 줄 바 꾸 지 않 기 기능 강화 인 스 턴 스

8/101 번 째 대본 입 니 다.
There are as many ways to solve this quirky echo problem as there are pages in this book. One of my favorites is very succinct:

function echon
{
 echo "$*" | awk '{ printf "%s" $0 }'
}
You may prefer to avoid the overhead incurred when calling the awk command, however, and if you have a user-level command called printf you can use it instead:

echon()
{
 printf "%s" "$*"
}
But what if you don't have printf and you don't want to call awk? Then use the tr command:

echon()
{
 echo "$*" | tr -d '
' }
This method of simply chopping out the carriage return with tr is a simple and efficient solution that should be quite portable.
이 스 크 립 트 는 매우 간단 합 니 다.바로 세 가지 서로 다른 함수(방법)로 이 루어 질 수 있 습 니 다.출력 후 줄 을 바 꾸 지 않 습 니 다.

좋은 웹페이지 즐겨찾기