This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #set +x | |
| # Create an array named as param ($1) or 'FOO' | |
| # and fill it with random numbers without naming it | |
| rand() { | |
| declare -n ref="${1:-FOO}" | |
| for i in {1..10}; do | |
| ref[$i]=$RANDOM | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #set -x | |
| function job { | |
| : ${RANDOM:0:2} | |
| sleep $_ && echo "Job $1 done in $_ sec" | |
| } | |
| for n in {1..12}; do | |
| if [[ ${jobs:=0} -ge 3 ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #set -x | |
| dir="$(mktemp -d)" | |
| mkfifo "${fifo:=$dir/FIFO}" | |
| inotifywait -m -e create $dir 1>$fifo 2>/dev/null & jobs %% | |
| for i in {1..10}; do | |
| ( sleep 2; touch "$dir/$i" ) & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| __iterate_on_args() { | |
| for a; do echo "arg: $a"; done | |
| } | |
| __iterate_on_glob() { | |
| #shopt -o nullglob | |
| for f in *."${1:-sh}"; do | |
| echo "file: $f" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function read { | |
| declare -n var="${@: -1}" | |
| case "$1" in | |
| -Z) until [[ -n "$var" ]]; do | |
| builtin read "${@:2}"; | |
| done ;; | |
| -D) until [[ "$var" =~ ^[0-9]+$ ]]; do | |
| builtin read "${@:2}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=JDownloader Headless | |
| After=network.target | |
| [Service] | |
| Restart=on-failure | |
| User=jdownloader | |
| Group=jdownloader | |
| LogsDirectory=jdownloader | |
| StateDirectory=jdownloader |
NewerOlder