10 Pipe, Filter, Redirection
νμ΄ν (|)
νμ΄νλ λ κ°μ λͺ
λ Ήμ΄λ₯Ό μ°κ²°νλ λ° μ¬μ©λ©λλ€. ν λͺ
λ Ήμ΄μ μΆλ ₯μ΄ λ€λ₯Έ λͺ
λ Ήμ΄μ μ
λ ₯μΌλ‘ μ λ¬λ©λλ€.
μλ₯Ό λ€μ΄, λ€μκ³Ό κ°μ΄ μ¬μ©ν μ μμ΅λλ€.
νν° (grep)
grepμ νΉμ ν¨ν΄μ΄λ ν μ€νΈλ₯Ό κ²μνλ λ° μ¬μ©λλ λͺ λ Ήμ΄μ λλ€. κΈ°λ³Έμ μΌλ‘λ νμ€ μ λ ₯μμ ν μ€νΈλ₯Ό μ½μ΄ ν¨ν΄μ λ§λ λΌμΈλ§ μΆλ ₯ν©λλ€. μλ₯Ό λ€μ΄, λ€μκ³Ό κ°μ΄ μ¬μ©ν μ μμ΅λλ€.
리λλ μ
리λλ μ μ λͺ λ Ήμ μ μΆλ ₯μ μ‘°μ νλ λ° μ¬μ©λ©λλ€.
- >λ μΆλ ₯μ νμΌλ‘ 리λλ μ νλ λ° μ¬μ©λλ©°, >>λ κΈ°μ‘΄ νμΌμ λ΄μ©μ μΆκ°ν©λλ€.
- <λ νμΌμ μ λ ₯μΌλ‘ μ¬μ©νλ λ° μ¬μ©λ©λλ€.
μλ₯Ό λ€μ΄,
νμ΄νμ ν¨κ» μ¬μ©ν μλ μμ΅λλ€.
Example
Foreground & Background
ν¬κ·ΈλΌμ΄λ(Foreground)μ λ°±κ·ΈλΌμ΄λ(Background)λ μ»΄ν¨ν° μ΄μ체μ μ νλ‘μΈμ€ μ€ν κ΄λ ¨ μ©μ΄λ‘ μ¬μ©λ©λλ€.
ν¬κ·ΈλΌμ΄λ (Foreground)
- ν¬κ·ΈλΌμ΄λλ μ¬μ©μμ μ§μ μνΈμμ©νλ νλ‘μΈμ€λ μμ© νλ‘κ·Έλ¨μ λνλ λλ€.
- μ¬μ©μκ° μ€νν νλ‘κ·Έλ¨μ΄λ νμ¬ νμ±νλ μ°½μ΄ ν¬κ·ΈλΌμ΄λμμ μ€ν μ€μΌ λ, ν΄λΉ νλ‘κ·Έλ¨μ μ¬μ©μμ μνΈμμ©ν μ μλ μνμ μμ΅λλ€.
- μΌλ°μ μΌλ‘, μ¬μ©μκ° ν€λ³΄λ λλ λ§μ°μ€λ₯Ό ν΅ν΄ νλ‘κ·Έλ¨κ³Ό μνΈμμ©ν λ, ν΄λΉ νλ‘κ·Έλ¨μ ν¬κ·ΈλΌμ΄λμμ μ€νλ©λλ€.
λ°±κ·ΈλΌμ΄λ (Background)
- λ°±κ·ΈλΌμ΄λλ μ¬μ©μμ μ§μ μνΈμμ©νμ§ μλ νλ‘μΈμ€λ μμ μ λνλ λλ€.
- μ¬μ©μκ° μ΄λ€ νλ‘κ·Έλ¨μ μ€ννκ³ λμ, ν΄λΉ νλ‘κ·Έλ¨μ΄ λ°±κ·ΈλΌμ΄λμμ μ€ν μ€μ΄λ©΄ μ¬μ©μλ λ€λ₯Έ μμ μ μννκ±°λ λ€λ₯Έ νλ‘κ·Έλ¨μ μ€νν μ μμ΅λλ€.
- λ°±κ·ΈλΌμ΄λμμ μ€ν μ€μΈ νλ‘μΈμ€λ λ³΄ν΅ μμ€ν 리μμ€λ₯Ό μ¬μ©νλ©°, μ¬μ©μμ μ£Όμλ₯Ό λμ§ μκ³ λμν©λλ€.
ν¬κ·ΈλΌμ΄λμ λ°±κ·ΈλΌμ΄λλ μ¬μ©μ κ²½νκ³Ό μμ€ν μ±λ₯μ μν₯μ λ―ΈμΉλ μ€μν 컨μ μ λλ€. νλ‘μΈμ€λ₯Ό ν¬κ·ΈλΌμ΄λ λλ λ°±κ·ΈλΌμ΄λμμ μ€ννλ κ²μ μ¬μ©μμ μꡬμ λ°λΌ μ μ νκ² μ νλμ΄μΌ ν©λλ€. μΌλΆ μμ μ μ¬μ©μμ μ§μ μ μΈ κ΄μ¬λ₯Ό νμλ‘ νμ§ μμΌλ―λ‘ λ°±κ·ΈλΌμ΄λμμ μ€νλλ©°, λ€λ₯Έ μμ μ μ¬μ©μμμ μνΈμμ©μ΄ νμνλ―λ‘ ν¬κ·ΈλΌμ΄λμμ μ€νλ©λλ€.
μ΄λ¬ν 리λ μ€ λͺ λ Ήμ΄λ€μ μ λμ€ μ²΄κ³μμ νμλ κ²μΌλ‘, ν°λ―Έλμμ ν¨κ³Όμ μΌλ‘ μ¬μ©ν μ μμ΅λλ€. μ΄λ¬ν λͺ λ Ήμ΄λ€μ μ‘°ν©νμ¬ λ³΅μ‘ν μμ μ μνν μ μμ΅λλ€.
νμ΄ν (Pipe)
Definition: A command in Unix-like operating systems that connects the output of one command to the input of another, allowing them to work together.
νν° (grep)
Definition: A command-line utility used to search for a specific pattern or text in a stream of data, often used in conjunction with other commands.
리λλ μ
(Redirection)
Definition: The process of adjusting the input or output of a command in Unix-like systems. ">" redirects output to a file, ">>" appends output to a file, and "<" redirects input from a file.
ν¬κ·ΈλΌμ΄λ (Foreground)
Definition: The active execution state of a program or process that directly interacts with the user, typically receiving input and providing output in real-time.
λ°±κ·ΈλΌμ΄λ (Background)
Definition: The execution state of a program or process that runs independently of user interaction, allowing users to perform other tasks while it operates.