티스토리 뷰

Linux

[Linux] >, >>, <, | 간단한 예제

Mr.Ban 2022. 8. 18. 17:18

용어

Redirection

output :  > (Overwrite), >> (append)

input : <

pipeline : |

 

예제

echo 'hi' > test.txt
cat test.txt
# hi

echo 'hello' > test.txt
cat test.txxt
# hello

echo 'hi' >> test.txt	# append
cat test.txt
# hello
# hi

cat < test.txt	# input
# hello
# hi

grep hel test.txt
# hello

grep hel < test.txt # input
# hello

cat test.txt | grep hel	# pipline
# hello

cat test.txt | grep hel > test2.txt # pipeline & redirection
cat test2.txt
# hello

 

'Linux' 카테고리의 다른 글

[Linux] mount 실습 예제  (0) 2023.01.15
[Linux] Disk partition 하기 (fdisk)  (0) 2023.01.15
[Linux] service vs systemctl 차이, /etc/init.d 용도  (0) 2022.08.17
Linux 화면 보호기 해제  (0) 2022.07.11
Linux 사용자 확인 및 삭제  (0) 2022.07.11
댓글