diff --git a/pages/common/$.md b/pages/common/$.md new file mode 100644 index 0000000000000..d193e4237be5c --- /dev/null +++ b/pages/common/$.md @@ -0,0 +1,24 @@ +# Dollar sign + +> Expand a bash variable. +> More information: . + +- Print a variable: + +`echo ${{VARIABLE}}` + +- Print the exit status of the previous command: + +`echo $?` + +- Print a random number between 0 and 32767: + +`echo $RANDOM` + +- Print one of the prompt strings: + +`echo ${{PS1|PS2|PS3|PS4}}` + +- Expand with the output of `command` and run it. Same as enclosing `command` in backtics: + +`$({{command}})` diff --git a/pages/common/greater-than.md b/pages/common/greater-than.md new file mode 100644 index 0000000000000..93c6e537d8bd0 --- /dev/null +++ b/pages/common/greater-than.md @@ -0,0 +1,20 @@ +# Greater than + +> Redirect output to a file. +> More information: . + +- Redirect `stdout` to a file: + +`{{command}} > {{path/to/file}}` + +- Append to a file: + +`{{command}} >> {{path/to/file}}` + +- Redirect both `stdout` and `stderr` to a file: + +`{{command}} &> {{path/to/file}}` + +- Redirect both `stdout` and `stderr` to `/dev/null` to keep the terminal output clean: + +`{{command}} &> /dev/null` diff --git a/pages/common/less-than.md b/pages/common/less-than.md new file mode 100644 index 0000000000000..e1fdfbe7a79ee --- /dev/null +++ b/pages/common/less-than.md @@ -0,0 +1,9 @@ +# Less than + +> Redirect a file to `stdin`. +> Achieves the same effect as `cat file.txt |`. +> More information: . + +- Redirect a file to `stdin`: + +`{{command}} < {{path/to/file.txt}}` diff --git a/pages/common/vertical-bar.md b/pages/common/vertical-bar.md new file mode 100644 index 0000000000000..153cda597aa0f --- /dev/null +++ b/pages/common/vertical-bar.md @@ -0,0 +1,12 @@ +# Vertical bar + +> Pipe data between programs. +> More information: . + +- Pipe `stdout` to `stdin`: + +`{{command}} | {{command}}` + +- Pipe both `stdout` and `stderr` to `stdin`: + +`{{command}} |& {{command}}`