summaryrefslogtreecommitdiffstats
path: root/tests/cheats/more_cases.cheat
blob: dc3003cbb1eb31f1f6e0c18cc9246660b693e675 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
; author: CI/CD

% test, ci/cd

# escape code + subshell
echo -ne "\033]0;$(hostname)\007"

# env var
echo "$HOME"

# multi + column
myfn() {
    for i in $@; do
        echo -e "arg: $i\n"
    done
}
folders=($(echo "<multi_col>"))
myfn "${folders[@]}"

# second column: default delimiter
echo "<table_elem> is cool"

# second column: custom delimiter
echo "<table_elem2> is cool"

# return multiple results: single words
echo "I like these languages: "$(printf '%s' "<langs>" | tr '\n' ',' | sed 's/,/, /g')""

# return multiple results: multiple words
echo "I like these examples: "$(printf '%s' "<examples>" | sed 's/^..*$/"&"/' | awk 1 ORS=', ' | sed 's/, $//')""

# multiple replacements -> "foo"
echo "<x> <y> <x> <z>"

$ x: echo '1 2 3' | tr ' ' '\n'
$ y: echo 'a b c' | tr ' ' '\n'
$ z: echo 'foo bar' | tr ' ' '\n'
$ table_elem: echo -e '0  rust      rust-lang.org\n1  clojure   clojure.org' --- --column 2
$ table_elem2: echo -e '0;rust;rust-lang.org\n1;clojure;clojure.org' --- --column 2 --delimiter ';'
$ multi_col: ls -la | awk '{print $1, $9}' --- --column 2 --delimiter '\s' --multi
$ langs: echo 'clojure rust javascript' | tr ' ' '\n' --- --multi
$ examples: echo -e 'foo bar\nlorem ipsum\ndolor sit' --- --multi
$ multiword: echo -e 'foo bar\nlorem ipsum\ndolor sit\nbaz'

# this should be displayed
echo hi