OSDN Git Service

Regular updates
[twpd/master.git] / bash.md
diff --git a/bash.md b/bash.md
index a7174ee..bb6114b 100644 (file)
--- a/bash.md
+++ b/bash.md
@@ -649,6 +649,7 @@ python hello.py &>/dev/null    # stdout and stderr to (null)
 
 ```bash
 python hello.py < foo.txt      # feed foo.txt to stdin for python
+diff <(ls -r) <(ls)            # Compare two stdout without files
 ```
 
 ### Inspecting commands
@@ -708,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
@@ -754,12 +777,13 @@ read -n 1 ans    # Just one character
 
 ### Special variables
 
-| Expression | Description                  |
-| ---------- | ---------------------------- |
-| `$?`       | Exit status of last task     |
-| `$!`       | PID of last background task  |
-| `$$`       | PID of shell                 |
-| `$0`       | Filename of the shell script |
+| Expression | Description                            |
+| ---------- | -------------------------------------- |
+| `$?`       | Exit status of last task               |
+| `$!`       | PID of last background task            |
+| `$$`       | PID of shell                           |
+| `$0`       | Filename of the shell script           |
+| `$_`       | Last argument of the previous command  |
 
 See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).