> For the complete documentation index, see [llms.txt](https://devops-3.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devops-3.gitbook.io/devops/docs/linux-cheat-sheet/text-processing.md).

# Text Processing

| Command                                                     | Description                                                      | Example                                                                 |
| ----------------------------------------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------- |
| <mark style="color:red;">**cat**</mark>                     | Concatenate and display file contents.                           | cat file.txt → Displays the content of file.txt.                        |
| <mark style="color:red;">**grep \[pattern] \[file]**</mark> | Search for a pattern in a file.                                  | grep "error" log.txt → Searches for "error" in log.txt.                 |
| <mark style="color:red;">**awk**</mark>                     | Pattern scanning and processing language.                        | awk '{print $1}' file.txt → Prints the first column of file.txt.        |
| <mark style="color:red;">**sed**</mark>                     | Stream editor for text manipulation.                             | sed 's/old/new/g' file.txt → Replaces "old" with "new" in file.txt.     |
| <mark style="color:red;">**sort**</mark>                    | Sort lines of text files.                                        | sort file.txt → Sorts the lines in file.txt.                            |
| <mark style="color:red;">**cut**</mark>                     | Remove sections from each line of a file.                        | cut -d',' -f1 file.csv → Extracts the first column from file.csv.       |
| <mark style="color:red;">**uniq**</mark>                    | Report or omit repeated lines.                                   | uniq file.txt → Removes duplicate lines from file.txt.                  |
| <mark style="color:red;">**tr**</mark>                      | Translate or delete characters.                                  | tr 'a-z' 'A-Z' → Converts lowercase letters to uppercase.               |
| <mark style="color:red;">**wc**</mark>                      | Count lines, words, and characters in a file.                    | wc file.txt → Displays the line, word, and character count of file.txt. |
| <mark style="color:red;">**tee**</mark>                     | Read from standard input and write to standard output and files. | \`echo "Hello"                                                          |
