sed (short for stream editor) is a powerful command-line utility used for parsing and transforming text in Unix and Unix-like operating systems. It is commonly used for tasks such as text substitution, deletion, and insertion.
Key Features:
- Text Manipulation:
sedcan perform complex text transformations using simple commands. - Non-Interactive: It processes input text in a non-interactive manner, making it suitable for batch processing.
- Regular Expressions: Supports regular expressions for pattern matching, allowing for flexible text manipulation.
- In-Place Editing: With the
-ioption,sedcan modify files directly without needing to create a separate output file.
Common Use Cases:
- Replacing text in files (e.g., changing "foo" to "bar").
- Deleting specific lines or patterns from files.
- Extracting specific data from structured text.
Example:
To replace "apple" with "orange" in a file named fruits.txt, you would use:
sed -i 's/apple/orange/g' fruits.txt
If you have more questions about sed or need examples, feel free to ask!
