mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-08-28 20:11:19 +08:00
Bash builtins: refresh pages (#19967)
This commit is contained in:
+6
-2
@@ -5,9 +5,13 @@
|
||||
> See also: `test`.
|
||||
> More information: <https://gnu.org/software/bash/manual/bash.html#index-test>.
|
||||
|
||||
- Test if a given variable is equal/not equal to the specified string:
|
||||
- Test if a given variable is equal to the specified string:
|
||||
|
||||
`[ "${{variable}}" {{=|!=}} "{{string}}" ]`
|
||||
`[ "${{variable}}" = "{{string}}" ]`
|
||||
|
||||
- Test if a given variable is not equal to the specified string:
|
||||
|
||||
`[ "${{variable}}" != "{{string}}" ]`
|
||||
|
||||
- Test if a given variable is [eq]ual/[n]ot [e]qual/[g]reater [t]han/[l]ess [t]han/[g]reater than or [e]qual/[l]ess than or [e]qual to the specified number:
|
||||
|
||||
|
||||
+4
-4
@@ -4,13 +4,13 @@
|
||||
> Returns a status of 0 if the condition evaluates to true, 1 if it evaluates to false.
|
||||
> More information: <https://gnu.org/software/bash/manual/bash.html#index-_005b_005b>.
|
||||
|
||||
- Test if a given variable is equal/not equal to the specified string:
|
||||
- Test if a given variable is equal to the specified string or glob:
|
||||
|
||||
`[[ ${{variable}} {{==|!=}} "{{string}}" ]]`
|
||||
`[[ ${{variable}} == "{{string}}" ]]`
|
||||
|
||||
- Test if a given string conforms the specified glob/`regex`:
|
||||
- Test if a given string conforms the specified `regex`:
|
||||
|
||||
`[[ ${{variable}} {{==|=~}} {{pattern}} ]]`
|
||||
`[[ ${{variable}} =~ {{pattern}} ]]`
|
||||
|
||||
- Test if a given variable is [eq]ual/[n]ot [e]qual/[g]reater [t]han/[l]ess [t]han/[g]reater than or [e]qual/[l]ess than or [e]qual to the specified number:
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# bg
|
||||
|
||||
> Resume suspended jobs (e.g. using `<Ctrl z>`), and keeps them running in the background.
|
||||
> Resume suspended jobs (e.g. using `<Ctrl z>`), and keep them running in the background.
|
||||
> See also: `jobs`, `fg`, `disown`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-bg>.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# command
|
||||
|
||||
> Command forces the shell to execute the program and ignore any functions, builtins and aliases with the same name.
|
||||
> Force the shell to execute the program and ignore any functions, builtins, and aliases with the same name.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-command>.
|
||||
|
||||
- Execute the `ls` program literally, even if an `ls` alias exists:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# continue
|
||||
|
||||
> Skip to the next iteration of a `for`, `while`, `until` or `select` loop.
|
||||
> Skip to the next iteration of a `for`, `while`, `until`, or `select` loop.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-continue>.
|
||||
|
||||
- Skip to the next iteration:
|
||||
|
||||
@@ -10,3 +10,7 @@
|
||||
- Disable a builtin (works in Bash only):
|
||||
|
||||
`enable -n {{command}}`
|
||||
|
||||
- Re-enable a builtin:
|
||||
|
||||
`enable {{command}}`
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
# false
|
||||
|
||||
> Returns a non-zero exit code.
|
||||
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/false-invocation.html>.
|
||||
> See also: `true`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-false>.
|
||||
|
||||
- Return a non-zero exit code:
|
||||
|
||||
`false`
|
||||
|
||||
- Make a command always exit with 1:
|
||||
|
||||
`{{command}} && false`
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
# fc
|
||||
|
||||
> Open the most recent command for editing and then run it.
|
||||
> Open the recent commands for editing and then run them.
|
||||
> See also: `history`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-fc>.
|
||||
|
||||
- Open the last command in the default system editor and run it after editing:
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# fg
|
||||
|
||||
> Run jobs in foreground.
|
||||
> See also: `jobs`, `bg`, `disown`.
|
||||
> See also: `jobs`, `bg`, `disown`, `%`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-fg>.
|
||||
|
||||
- Bring most recently suspended or running background job to foreground:
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
> Perform a command several times.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Looping-Constructs>.
|
||||
|
||||
- Iterate through command line arguments:
|
||||
- Iterate through command line parameters:
|
||||
|
||||
`for {{variable}}; do {{echo $variable}}; done`
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# getopts
|
||||
|
||||
> Parse shell options from arguments.
|
||||
> This command does not support longform options and thus using `getopt` is recommended instead.
|
||||
> Note: This command does not support longform options and thus using `getopt` is recommended instead.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-getopts>.
|
||||
|
||||
- Check if an option is the first set option in the current context:
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
- Print instructions on how to use `[[ ]]` for conditional commands:
|
||||
|
||||
`help [[ ]]`
|
||||
`help [[`
|
||||
|
||||
- Print instruction on how to use `(( ))` to evaluate arithmetic expressions:
|
||||
|
||||
`help \( \)`
|
||||
`help \(`
|
||||
|
||||
- Print instructions on how to use the `cd` command:
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# let
|
||||
|
||||
> Evaluate arithmetic expressions in shell.
|
||||
> Supports variables, operators, and conditional expressions.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-let>.
|
||||
|
||||
- Evaluate a simple arithmetic expression:
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# return
|
||||
|
||||
> Exit a function or a script if run with `source`.
|
||||
> Exit a function.
|
||||
> Can exit out of a script if run with `source`.
|
||||
> See also: `exit`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-return>.
|
||||
|
||||
- Exit a function prematurely:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
> Generic POSIX shell variables (stored in `$SHELLOPTS`) are managed with the `set` command instead.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin>.
|
||||
|
||||
- List of all settable options and whether they are set:
|
||||
- List of all setable options and whether they are set:
|
||||
|
||||
`shopt`
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# time
|
||||
|
||||
> Measure how long a command took to run.
|
||||
> Note: `time` can either exist as a shell builtin, a standalone program or both.
|
||||
> Note: `time` can either exist as a shell builtin, a standalone program, or both.
|
||||
> See also: `times`.
|
||||
> More information: <https://manned.org/time>.
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# times
|
||||
|
||||
> Print the cumulative CPU usage time of the current shell.
|
||||
> First line is current shell CPU usage for User and System. Second is all child processes.
|
||||
> See also: `time`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-times>.
|
||||
|
||||
- Print CPU usage. First line is current shell CPU usage for User and System. Second is all child processes:
|
||||
- Print CPU usage:
|
||||
|
||||
`times`
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
# true
|
||||
|
||||
> Returns a successful exit status code of 0.
|
||||
> Use this with the || operator to make a command always exit with 0.
|
||||
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/true-invocation.html>.
|
||||
> See also: `false`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-true>.
|
||||
|
||||
- Return a successful exit code:
|
||||
|
||||
`true`
|
||||
|
||||
- Make a command always exit with 0:
|
||||
|
||||
`{{command}} || true`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# ulimit
|
||||
|
||||
> Get and set resource limits for user processes.
|
||||
> It is a shell builtin hence not shell-agnostic.
|
||||
> This is a shell builtin hence not shell-agnostic.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-ulimit>.
|
||||
|
||||
- Get the properties of all the user limits:
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
> Remove shell variables or functions.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-unset>.
|
||||
|
||||
- Remove the variable `foo`, or if the variable doesn't exist, remove the function `foo`:
|
||||
- Remove variable, or if the variable doesn't exist, remove the function of the same name:
|
||||
|
||||
`unset {{foo}}`
|
||||
`unset {{variable}}`
|
||||
|
||||
- Remove the variables foo and bar:
|
||||
- Remove variables:
|
||||
|
||||
`unset -v {{foo}} {{bar}}`
|
||||
`unset -v {{variable1 variable2 ...}}`
|
||||
|
||||
- Remove the function my_func:
|
||||
- Remove the function:
|
||||
|
||||
`unset -f {{my_func}}`
|
||||
`unset -f {{function_name1 function_name2}}`
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
> Shell builtin for viewing information about processes spawned by the current shell.
|
||||
> Options other than `-l` and `-p` are exclusive to Bash.
|
||||
> See also: `fg`, `bg`, `disown`, `%`.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-jobs>.
|
||||
|
||||
- View jobs spawned by the current shell:
|
||||
|
||||
Reference in New Issue
Block a user