다음 명령을 사용하여 디렉토리 구조를 파일로 인쇄합니다.
tree -h somepath/ > tree_of_somepath.txt
tree
터미널에서 색상이 좋은 출력물을 제공하지만 예상대로 텍스트 파일로 리디렉션 할 수 없습니다. 출력을 tree
pdf 파일 로 인쇄 하고 색상을 유지하고 싶습니다 .
어떤 아이디어?
답변
-
다음 종속성을 설치하십시오.
sudo apt-get install aha wkhtmltopdf
-
다음을 사용하여
tree
명령 출력을 html로 저장하십시오aha
.tree -C -h | aha > foo.html
로부터
tree
man 페이지,-C
힘은 칼라 화 :-C Turn colorization on always, using built-in color defaults if the LS_COLORS environment variable is not set. Useful to colorize output to a pipe.
-
마지막으로 다음을 사용하여 html을 pdf로 내보내십시오
wkhtmltopdf
.wkhtmltopdf foo.html foo.pdf
예:
cd /tmp
tree -C -h | aha > foo.html
wkhtmltopdf foo.html foo.pdf
xdg-open foo.pdf