cleanup of language
This commit is contained in:
13
README.md
13
README.md
@@ -235,7 +235,7 @@ John Black is my name.
|
|||||||
|
|
||||||
## Use regex on a string
|
## Use regex on a string
|
||||||
|
|
||||||
We can use the result of `bash`'s regex matching to replace `sed` for a
|
The result of `bash`'s regex matching can be used to replace `sed` for a
|
||||||
large number of use-cases.
|
large number of use-cases.
|
||||||
|
|
||||||
**CAVEAT**: This is one of the few platform dependant `bash` features.
|
**CAVEAT**: This is one of the few platform dependant `bash` features.
|
||||||
@@ -895,8 +895,7 @@ $ lines_loop ~/.bashrc
|
|||||||
|
|
||||||
## Count files or directories in directory
|
## Count files or directories in directory
|
||||||
|
|
||||||
This works by passing the output of the glob as function arguments. We
|
This works by passing the output of the glob to the function and then counting the number of arguments.
|
||||||
then count the arguments and print the number.
|
|
||||||
|
|
||||||
**Example Function:**
|
**Example Function:**
|
||||||
|
|
||||||
@@ -1639,10 +1638,7 @@ f()for i in "$@"; do echo "$i"; done
|
|||||||
|
|
||||||
## Simpler `case` statement to set variable
|
## Simpler `case` statement to set variable
|
||||||
|
|
||||||
We can use the `:` builtin to avoid repeating `variable=` in a case
|
The `:` built-in can be used to avoid repeating `variable=` in a case statement. The `$_` variable stores the last argument of the last command. `:` always succeeds so it can be used to store the variable value.
|
||||||
statement. The `$_` variable stores the last argument of the last
|
|
||||||
successful command. `:` always succeeds so we can abuse it to store the
|
|
||||||
variable value.
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Modified snippet from Neofetch.
|
# Modified snippet from Neofetch.
|
||||||
@@ -1729,8 +1725,7 @@ fi
|
|||||||
|
|
||||||
## Get the current date using `strftime`
|
## Get the current date using `strftime`
|
||||||
|
|
||||||
Bash’s `printf` has a built-in method of getting the date which we can use
|
Bash’s `printf` has a built-in method of getting the date which can be used in place of the `date` command.
|
||||||
in place of the `date` command in a lot of cases.
|
|
||||||
|
|
||||||
**CAVEAT:** Requires `bash` 4+
|
**CAVEAT:** Requires `bash` 4+
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user