From 5a23b79e78d6910a168ddf80280022375763c47b Mon Sep 17 00:00:00 2001 From: verbatino Date: Sun, 13 Mar 2022 12:08:22 +0100 Subject: [PATCH] Add tr command to bash cheatsheet (#1802) Co-authored-by: Rico Sta. Cruz --- bash.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bash.md b/bash.md index 431f2d4b7..bb6114b4b 100644 --- a/bash.md +++ b/bash.md @@ -709,6 +709,28 @@ printf "This is how you print a float: %f" 2 #=> "This is how you print a float: 2.000000" ``` +### Transform strings + +| Command option | Description | +| ------------------ | --------------------------------------------------- | +| `-c` | Operations apply to characters not in the given set | +| `-d` | Delete characters | +| `-s` | Replaces repeated characters with single occurrence | +| `-t` | Truncates | +| `[:upper:]` | All upper case letters | +| `[:lower:]` | All lower case letters | +| `[:digit:]` | All digits | +| `[:space:]` | All whitespace | +| `[:alpha:]` | All letters | +| `[:alnum:]` | All letters and digits | + +#### Example + +```bash +echo "Welcome To Devhints" | tr [:lower:] [:upper:] +WELCOME TO DEVHINTS +``` + ### Directory of script ```bash