I'm n1 - I read, write and code.
Cheatsheets
Bash
Feh
Midnight Commander
MPV
NeoVim
NeoMutt
Nsxiv
Postgres
TeX
WeeChat
Zathura
Bash cheatsheet
Arrays
read -a my_var
- Reads list of strings from stdin to array my_var variable
mapfile -t my_var < file.txt
- Read lines from the standard input into an indexed array variable.
Cursor movement
\e[1;1H
- Moves cursor to 1:1 coordinates (absolutely)
\e[1A
- Moves cursor 1 line up (above) (relatively)
\e[1B
- Moves cursor 1 line down (bellow) (relatively)
\e[1C
- Moves cursor 1 column right (relatively)
\e[1D
- Moves cursor 1 column left (relatively)
more here
String operations
${#string}
- Extract substring from $string at $position
${string:position:length}
- Extract $length characters substring from $string at $position (0-based)
${string/substring/replacement}
- Replace first match of $substring with $replacement
${string//substring/replacement}
- Replace all matches of $substring with $replacement
${string/#substring/replacement}
- If $substring matches front end of $string, substitute $replacement for $substring
${string/%substring/replacement}
- If $substring matches back end of $string, substitute $replacement for $substring