Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:bash_script_skeleton [2019/07/22 06:28] (current)
Line 1: Line 1:
 +====== Bash Script Skeleton ======
 +<code bash>
 +#!/bin/bash
 +#
 +# .......... comment ............
 +#
 +NOW=$(date +"​%Y-%m-%d-%H-%M-%S"​)
 +#
 +#
 +if [[ ! ("​$#"​ == 1) ]]; then
 +  echo "One argument required."​
 +  exit 1
 +fi
 +#
 +exit 0
 +#
 +</​code>​
 +
 +Sleep a random amount of time between 0 and 10 minutes
 +<code bash>
 +sleep $((RANDOM%600))
 +</​code>​
 +
 +Check if file does not exist
 +<code bash>
 +if [ ! -f "​$HOSTFILE"​ ]; then
 +  echo "File: $HOSTFILE does not exist"
 +  exit 1
 +fi
 +</​code>​
  

QR Code
QR Code tech:linux:bash_script_skeleton (generated for current page)