Bash

Fill a file with random data

1
  dd if=/dev/urandom of=target-file bs=1M count=1000000

Suggested header

1
  set -euxo pipefail

constructs)

http://www.tldp.org/LDP/abs/html/options.html

Iterate over directories

1
  find . -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \;

Parsing options

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  REMOTE=
  PUSH=0

  while getopts "r:p" OPTION; do
    case $OPTION in
      r)
        REMOTE=$OPTARG
        ;;
      p)
        PUSH=1
        ;;
      ?)
        usage
        exit
        ;;
      esac
  done

Exec wrapper

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  #!/bin/bash

  on_die ()
  {
      # kill all children
      pkill -KILL -P $$
  }

  trap 'on_die' TERM
  ffmpeg -i rtmp://localhost/myapp/$1 -c copy -f flv rtmp://localhost/myapp2/$1 &
  wait

Filename

1
2
3
  function filename {
      return ${1%%.*}
  }

Extension

1
2
3
  function extname {
      return ${1#*.}
  }