«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Recent Posts
Today
Total
03-06 14:40
300x250
관리 메뉴

변군이글루 블로그(Development)

shell script EOF(End Of File) 사용하기 본문

리눅스

shell script EOF(End Of File) 사용하기

변군Dev 2022. 10. 19. 16:30
728x90

shell script EOF(End Of File) 사용하기

덮어쓰기(파일이 없으면 생성됨)

file1.txt

cat <<EOF > file1.txt
hello
world
EOF
$ cat file1.txt
hello
world

file2.txt

cat <<'EOF' | sed 's/l/e/g' > file2.txt
Hello
World
EOF
$ cat file2.txt 
Heeeo
Wored

file3.txt

cat > file3.txt <<EOF
hello
world
EOF
$ cat file3.txt        
hello
world
728x90

추가(파일 끝에 붙이기)

file5.txt

cat <<EOF >> file5.txt      
hello
world
EOF
cat <<EOF >> file5.txt
hello
world
EOF
$ cat file5.txt         
hello
world
hello
world

file6.txt

cat >> file6.txt << EOF
hello
world
EOF
cat >> file6.txt << EOF
hello
world
EOF
$ cat file6.txt
hello
world
hello
world

 

728x90