Skip to content

Commit 1b7205a

Browse files
author
elvis kahoro
committed
Creating a clean pr on behalf of wyatt-stanke: #54
1 parent 4e7ad1a commit 1b7205a

6 files changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--
2+
name: Append value(s) to an array
3+
command: "{{array_name}}+=({{values}})"
4+
tags:
5+
- shell
6+
description: Loops through an array, running a command on each value.
7+
arguments:
8+
- name: array_name
9+
description: The name of the array to append values
10+
default_value: ~
11+
- name: values
12+
description: The values to append to the array, space-separated
13+
default_value: ~
14+
source_url: "https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays"
15+
author: Wyatt-Stanke
16+
author_url: "https://github.com/Wyatt-Stanke"
17+
shells:
18+
- Zsh
19+
- Bash

specs/shell/array_create.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Make a new, empty array
3+
command: "{{array_name}}=()"
4+
tags:
5+
- shell
6+
description: Makes an empty array and assigns it to variable "array_name"
7+
arguments:
8+
- name: array_name
9+
description: The name of the array to create
10+
default_value: ~
11+
source_url: "https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays"
12+
author: Wyatt-Stanke
13+
author_url: "https://github.com/Wyatt-Stanke"
14+
shells:
15+
- Zsh
16+
- Bash

specs/shell/array_get_size.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Get number of elements in an array
3+
command: "echo ${#{{array_name}}[@]}"
4+
tags:
5+
- shell
6+
description: Gets the number of elements in an array, and prints it to stdout.
7+
arguments:
8+
- name: array_name
9+
description: The name of the array to get the size of
10+
default_value: ~
11+
source_url: "https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays"
12+
author: Wyatt-Stanke
13+
author_url: "https://github.com/Wyatt-Stanke"
14+
shells:
15+
- Zsh
16+
- Bash

specs/shell/array_get_value.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Get a value from an array
3+
command: "echo ${{{array_name}}[{{index}}]}"
4+
tags:
5+
- shell
6+
description: Gets a value from an array and prints it to stdout.
7+
arguments:
8+
- name: array_name
9+
description: The name of the array to get a value from
10+
default_value: ~
11+
- name: index
12+
description: The index of the value to get (starting at 0)
13+
default_value: ~
14+
source_url: "https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays"
15+
author: Wyatt-Stanke
16+
author_url: "https://github.com/Wyatt-Stanke"
17+
shells:
18+
- Zsh
19+
- Bash
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--
2+
name: Loop through an array and run a command on each value
3+
command: "for i in ${{{array_name}}[@]}; do {{command}}; done"
4+
tags:
5+
- shell
6+
description: Loops through an array, running a command on each value.
7+
arguments:
8+
- name: array_name
9+
description: The name of the array to loop through
10+
default_value: ~
11+
- name: command
12+
description: The command to run on each value in the array
13+
default_value: ~
14+
source_url: "https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays"
15+
author: Wyatt-Stanke
16+
author_url: "https://github.com/Wyatt-Stanke"
17+
shells:
18+
- Zsh
19+
- Bash

specs/shell/array_set_value.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Set an index in an array to a value
3+
command: "{{array_name}}[{{index}}]={{value}}"
4+
tags:
5+
- shell
6+
description: Makes an empty array and assigns it to variable "array_name"
7+
arguments:
8+
- name: array_name
9+
description: The name of the array to set the value
10+
default_value: ~
11+
- name: array_index
12+
description: The index of the array to set
13+
default_value: ~
14+
- name: value
15+
description: The value to set the array index to
16+
default_value: ~
17+
source_url: "https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays"
18+
author: Wyatt-Stanke
19+
author_url: "https://github.com/Wyatt-Stanke"
20+
shells:
21+
- Zsh
22+
- Bash

0 commit comments

Comments
 (0)