1
터미널에서 명령을 실행할 때 출력 할 것과 동일한 형식으로 명령의 출력을 반향시키고 싶습니다. 그러나 어떤 이유 때문에 echo를 사용하여 줄 바꿈을 제거하는 것처럼 보입니다.캡처 한 명령에서 여러 줄 출력을 에코하려면 어떻게합니까?
예 :
$ OUTPUT=$(git status)
$ echo $OUTPUT
# On branch feature_install # Untracked files: # (use "git add <file>..." to include in what will be committed) # # install/ nothing added to commit but untracked files present (use "git add" to track)
그러나 인쇄 했어야
$ git status
# On branch feature_install
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# install/
nothing added to commit but untracked files present (use "git add" to track)
또한 색 파싱 출력 유지 될 수 있는가? 큰 따옴표를 사용하면 줄 바꿈이 유지됩니다
색상이 없었습니다. git은 출력이 tty가 아니며 색상의 이스케이프 코드를 출력하지 않는다는 것을 알게되었습니다. –
OUTPUT 줄 앞에'IFS = '\ n''을 시도해보고 도움이되는지 확인하십시오. – bos
참조 http://unix.stackexchange.com/questions/17732/where-has-the-trailing-newline-char-gone-from-my-command-substitution –