본문 바로가기

IT/Linux

[Linux] cat << EOF > a.txt

here document, here-document, heredoc, hereis, here-string, here-script히어 문서, 히어 도큐먼트, 히어 다큐먼트, 히어 문자열, 히어닥

  • 문자열을 쉘스크립트나 프로그래밍 언어 중에 그대로 포함시키기 위한 방법
  • << 뒤에 식별자를 선언하고 원하는 문자열을 쓴 후에 식별자로 끝내면 된다.
  • 지원환경·언어: UNIX 계열 쉘스크립트(sh, csh, ksh, bash, zsh), Perl, PHP, Python, Ruby 등
[root@zetawiki ~]# cat << EOF > a.txt
> hello
> world
> EOF
[root@zetawiki ~]# cat a.txt
hello
world

EOF는 End of File, EOT는 End of Text이라는 의미이다.

cat <<EOF > file1.txt
hello
world
EOF
 
user01@localhost:~$ cat <<EOF > file1.txt
> hello
> world
> EOF
user01@localhost:~$ cat file1.txt
hello
world

 

 

 

리눅스 cat <<EOF - 제타위키

다음 문자열 포함...

zetawiki.com

 

'IT > Linux' 카테고리의 다른 글

[Linux] 프로세스 확인 & 죽이기 ps . kill 명령어  (0) 2023.01.20
[Linux] command terminal 단축키  (0) 2023.01.20
[Linux] opencv 설치 및 오류  (0) 2021.11.29
[Linux] PATH값 초기화 하기  (0) 2021.11.29
[Linux] ubuntu 버전 확인  (0) 2021.11.25