Update cheatsheets

This commit is contained in:
ivuorinen
2024-03-04 00:13:37 +00:00
parent d5be0a5308
commit 4fc14b09a3
10 changed files with 195 additions and 45 deletions

25
tldr/select Normal file
View File

@@ -0,0 +1,25 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# select
> Bash builtin construct for creating menus.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-select>.
- Create a menu out of individual words:
`select {{word}} in {{apple orange pear banana}}; do echo ${{word}}; done`
- Create a menu from the output of another command:
`select {{line}} in $({{command}}); do echo ${{line}}; done`
- Specify the prompt string for `select` and create a menu for picking a file or folder from the current directory:
`PS3="{{Select a file: }}"; select {{file}} in *; do echo ${{file}}; done`
- Create a menu from a Bash array:
`{{fruits}}=({{apple orange pear banana}}); select {{word}} in ${{{fruits[@]}}}; do echo ${{word}}; done`