![실행 중인 프로세스를 동적으로 표시하시겠습니까?](https://linux55.com/image/21585/%EC%8B%A4%ED%96%89%20%EC%A4%91%EC%9D%B8%20%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%EB%A5%BC%20%EB%8F%99%EC%A0%81%EC%9C%BC%EB%A1%9C%20%ED%91%9C%EC%8B%9C%ED%95%98%EC%8B%9C%EA%B2%A0%EC%8A%B5%EB%8B%88%EA%B9%8C%3F.png)
나는 실행할 때 특정 정보가 출력 화면에 표시되는 스크립트를 작성하고 있습니다.
예를 들어일정한 데이터표시되는 내용은 다음과 같습니다.
my name is mukesh.
i am 27 years old
unix version 7.2.3.0
하지만 위의 표시 외에도 다른 콘텐츠를 표시해야 합니다(다른 데이터)즉
Process A is starting
Process A is running
Process A is completed.
하지만 나는 위의 디스플레이를 원하지 않습니다.
Process A is starting
화면을 지우고 Process A is running
then by 로 바꾸고 싶습니다 .Process A is completed.
clear
포함된 전체 화면을 제거하므로 사용하고 싶지 않습니다.일정한 데이터반품. 하지만 일정한 데이터를 처리하고 화면에 표시하는 데 많은 시간이 걸리기 때문입니다.
답변1
줄을 지우고 캐리지 리턴( \r
)을 사용하여 줄의 시작 부분으로 이동할 수 있습니다.
clr2eol=`tput el` # capture escape sequence for "clear-to-end-of-line"
echo -n "Process A has started." # display without a newline
sleep 3
echo -n "\r${clr2eol}Process A is running." # move to beginning of line (bol), clear, and display new text
sleep 5
echo -n "\r${clr2eol}Process A has completed." # again, move to bol, clear and display new test
echo # terminating newline you may not want to have this sent right away
맨페이지 읽기terminfo
.
답변2
캐리지 리턴( \r
)을 사용하면 현재 줄의 시작 부분으로 돌아가므로 텍스트를 덮어쓸 수 있습니다.
printf "%s\r" "Process A is starting "
sleep 5
printf "%s\r" "Process A is running "
sleep 5
printf "%s\n" "Process A is completed."
답변3
이와 같은 작업을 수행하려면 (n)curses와 같은 것을 사용해야 합니다.http://www.gnu.org/software/ncurses/