myhelp:bash
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| myhelp:bash [2024/03/07 12:12] – created - external edit 127.0.0.1 | myhelp:bash [2026/04/22 11:48] (current) – ulrich | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | # Read a file per line | + | ====== |
| - | ``` | + | < |
| # while read line; do echo " | # while read line; do echo " | ||
| - | ``` | + | </ |
| - | # Upper to Lower | + | ====== |
| Is pretty easy done | Is pretty easy done | ||
| - | ``` | + | < |
| # cat / | # cat / | ||
| - | ``` | + | </ |
| or | or | ||
| - | ``` | + | < |
| # echo " | # echo " | ||
| - | ``` | + | </ |
| - | # SED Examples | + | ====== |
| Delete a line with a string in it. For example old ssh-keys: | Delete a line with a string in it. For example old ssh-keys: | ||
| - | ``` | + | < |
| # sed -i "/ | # sed -i "/ | ||
| - | ``` | + | </ |
| - | # Calculate | + | ====== |
| You can use the expr | You can use the expr | ||
| - | ``` | + | < |
| # expr 1 + 2 | # expr 1 + 2 | ||
| - | ``` | + | </ |
| and you will get 3 as result. | and you will get 3 as result. | ||
| Line 39: | Line 39: | ||
| Also some more fancy stuff is possible. For example in a for-loop: | Also some more fancy stuff is possible. For example in a for-loop: | ||
| - | ``` | + | < |
| for i in {1..9}; do echo " | for i in {1..9}; do echo " | ||
| - | ``` | + | </ |
| - | # Bash redirection | + | ====== |
| stdout to file | stdout to file | ||
| - | ``` | + | < |
| # command > file.txt | # command > file.txt | ||
| - | ``` | + | </ |
| stderr to file | stderr to file | ||
| - | ``` | + | < |
| # command 2> /dev/null | # command 2> /dev/null | ||
| - | ``` | + | </ |
| stdout AND stderr to file | stdout AND stderr to file | ||
| - | ``` | + | < |
| # command &> file.txt | # command &> file.txt | ||
| - | ``` | + | </ |
| stdout to file AND stderr to file | stdout to file AND stderr to file | ||
| - | ``` | + | < |
| # command > file.txt 2> /dev/null | # command > file.txt 2> /dev/null | ||
| - | ``` | + | </ |
| stdout to stderr | stdout to stderr | ||
| - | ``` | + | < |
| # command 1>&2 | # command 1>&2 | ||
| - | ``` | + | </ |
| stderr to stdout | stderr to stdout | ||
| - | ``` | + | < |
| # command 2>&1 | # command 2>&1 | ||
| - | ``` | + | </ |
myhelp/bash.1709813569.txt.gz · Last modified: by 127.0.0.1 · Currently locked by: 216.73.216.196
