Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
linux:shell [2024/04/21 13:43] cyril |
linux:shell [2024/12/11 09:40] (current) cyril [Misc] |
||
|---|---|---|---|
| Line 72: | Line 72: | ||
| BASEDIR=$(dirname " | BASEDIR=$(dirname " | ||
| </ | </ | ||
| - | * **echo to stderr**, just redirect the output:< | + | * **echo to stderr**, just redirect the output:< |
| echo " | echo " | ||
| </ | </ | ||
| + | * **Convert dash-time to ISO** (2024-04-21_15-50-30 to 2024-04-21T15: | ||
| + | sed -r " | ||
| + | </ | ||
| + | * **Get target name of symbolic link**:< | ||
| + | readlink < | ||
| + | </ | ||
| + | * **Execute command**:< | ||
| + | var=`cat file` | ||
| + | var=$(cat file) | ||
| + | </ | ||
| + | * **Evaluate mathematical expression** ('' | ||
| + | echo $((2*3)) | ||
| + | </ | ||
| + | * **time with redirected output** (also works for groups of commands):< | ||
| + | time (cat file1 > file2) | ||
| + | time (cat file1 > /dev/null; sync) | ||
| + | </ | ||
| + | * **Check number of arguments and print usage: | ||
| + | if [[ $# -lt 2 ]]; then | ||
| + | echo " | ||
| + | exit 1 | ||
| + | fi | ||
| + | </ | ||
| + | * **Load command output as a file: | ||
| + | diff <(grep x file1) <(grep y file2) | ||
| + | </ | ||
| + | * **Remove extension from file name: | ||
| + | ${f%.png} # with all shells | ||
| + | ${f: | ||
| + | </ | ||
| + | |||
| + | |||
