2020-03-19 12:19:50 +00:00
|
|
|
; author: CI/CD
|
|
|
|
|
2020-08-23 23:09:27 +00:00
|
|
|
% test, first
|
2020-03-19 12:19:50 +00:00
|
|
|
|
|
|
|
# trivial case -> "foo"
|
|
|
|
echo "foo"
|
|
|
|
|
2021-08-07 13:52:30 +00:00
|
|
|
# map -> "_foo_"
|
|
|
|
echo "<map1>"
|
|
|
|
|
2021-08-07 15:07:17 +00:00
|
|
|
# duplicated lines -> "foo\nlorem ipsum\nlorem ipsum\nbaz"
|
|
|
|
echo foo
|
|
|
|
echo lorem ipsum
|
|
|
|
echo lorem ipsum
|
|
|
|
echo baz
|
|
|
|
|
2021-08-07 13:52:30 +00:00
|
|
|
# expand -> "foo"
|
|
|
|
echo "<expand1>"
|
|
|
|
|
2020-03-19 12:19:50 +00:00
|
|
|
# sed with replacement -> "172.17.0.2"
|
|
|
|
echo "8.8.8.8 via 172.17.0.1 dev eth0 src 172.17.0.2" | sed -E 's/.*src ([0-9.]+).*/\1/p' | head -n1
|
|
|
|
|
|
|
|
# 2nd column with default delimiter -> "rust is cool"
|
|
|
|
echo "<language> is cool"
|
|
|
|
|
|
|
|
# 2nd column with custom delimiter -> "clojure is cool"
|
|
|
|
echo "<language2> is cool"
|
|
|
|
|
|
|
|
# multiple words -> "lorem foo bar ipsum"
|
|
|
|
echo "lorem <multiword> ipsum"
|
|
|
|
|
2020-08-14 16:53:23 +00:00
|
|
|
# variable dependency, full -> "2 12 a 2"
|
2020-03-19 12:19:50 +00:00
|
|
|
echo "<x> <x2> <y> <x>"
|
|
|
|
|
2020-08-28 12:58:35 +00:00
|
|
|
; # variable dependency, we can ignore intermediate values -> "foo 12"
|
|
|
|
; printf "foo "; : <x>; echo "<x2>"
|
2020-08-14 16:53:23 +00:00
|
|
|
|
|
|
|
# nested unused value -> "path: /my/pictures"
|
|
|
|
echo "path: <pictures_folder>"
|
|
|
|
|
2021-01-18 16:03:39 +00:00
|
|
|
# multiline command: no backslash -> "foo\nbar"
|
|
|
|
echo "foo"
|
|
|
|
echo "bar"
|
|
|
|
|
|
|
|
# multiline command: with backslash -> "lorem ipsum\nno match"
|
|
|
|
echo 'lorem ipsum'
|
|
|
|
echo "foo" \
|
|
|
|
| grep -q "bar" \
|
|
|
|
&& echo "match" \
|
|
|
|
|| echo "no match"
|
|
|
|
|
2020-03-19 12:19:50 +00:00
|
|
|
$ x: echo '2'
|
|
|
|
$ x2: echo "$((x+10))"
|
|
|
|
$ y: echo 'a'
|
|
|
|
$ language: echo '0 rust rust-lang.org' --- --column 2
|
|
|
|
$ language2: echo '1;clojure;clojure.org' --- --column 2 --delimiter ';'
|
|
|
|
$ multiword: echo 'foo bar'
|
2020-08-14 16:53:23 +00:00
|
|
|
$ pictures_folder: echo "/my/pictures"
|
2021-08-07 13:52:30 +00:00
|
|
|
$ map1: echo "foo" --- --map 'echo _$(cat)_'
|
|
|
|
$ expand1: echo "foo" --- --expand
|
2020-03-19 12:19:50 +00:00
|
|
|
|
|
|
|
# this should be displayed -> "hi"
|
2020-08-23 23:09:27 +00:00
|
|
|
echo hi
|
|
|
|
|
|
|
|
|
|
|
|
% test, second
|
|
|
|
|
|
|
|
@ test, first
|
|
|
|
@ test, third
|
|
|
|
|
|
|
|
# nested used value -> "path: /my/pictures/wallpapers"
|
|
|
|
echo "path: <wallpaper_folder>"
|
|
|
|
|
|
|
|
# same command as before -> "12"
|
|
|
|
: <x>; echo "<x2>"
|
|
|
|
|
|
|
|
# the order isn't relevant -> "br"
|
|
|
|
echo "<country>"
|
|
|
|
|
|
|
|
$ wallpaper_folder: echo "<pictures_folder>/wallpapers"
|
|
|
|
|
|
|
|
|
|
|
|
% test, third
|
|
|
|
|
|
|
|
; this cheathsheet doesnt have any commands
|
|
|
|
$ country: echo "br"
|