Stream Types Overview
Stream Classification
Linux supports multiple stream types, each serving specific purposes in system and application interactions:
1. Text Streams
Text streams handle human-readable character data, commonly used for configuration files and log processing.
## Example of text stream processing
cat /etc/passwd | cut -d: -f1
2. Binary Streams
Binary streams manage raw byte data, essential for low-level system operations and file transfers.
graph LR
A[Binary Stream] --> B[Raw Byte Data]
A --> C[No Text Encoding]
A --> D[Direct Memory Manipulation]
3. Network Streams
Network streams facilitate communication between distributed systems and processes.
Stream Type |
Protocol |
Characteristics |
TCP Stream |
Connection-oriented |
Reliable, ordered |
UDP Stream |
Connectionless |
Fast, lightweight |
4. Pipe Streams
Pipe streams enable inter-process communication and data flow between commands.
## Pipe stream example
ps aux | grep python
Stream Handling Techniques
Redirection Methods
- Input Redirection:
<
- Output Redirection:
>
- Error Redirection:
2>
Advanced Stream Operations
## Combining stdout and stderr
command 2>&1 output.log
## Appending to streams
echo "LabEx Stream Tutorial" >> log.txt
graph TD
A[Stream Performance] --> B[Buffer Size]
A --> C[Data Type]
A --> D[Processing Method]
- Buffer allocation
- Data encoding
- Processing complexity