cat 명령어로 파일에 여러줄 입력하기 :: 행복한 프로그래머

posted by 쁘로그램어 2020. 6. 29. 22:51

cat 명령어를 이용해서 print.sh 라는 파일에 여러줄을 입력하는 방법이다.

$ cat <<EOF > print.sh

#!/bin/bash

echo \$PWD

echo $PWD

EOF


# 참고사이트

https://en.wikipedia.org/wiki/Here_document#Unix_shells

https://stackoverflow.com/questions/2500436/how-does-cat-eof-work-in-bash

https://www.cyberciti.biz/faq/using-heredoc-rediection-in-bash-shell-script-to-write-to-file/