chmod u+x script-name-here.sh

./script-name-here.sh sh script-name-here.sh bash script-name-here.sh

script <filename.log> # default is 'typescript'
# other commands
exit # or ctrl-c

script -c '<command>' <filename.log> # output of single command to log

less <filename.log> # to view
scriptreplay -s <filename.log> --timing=time.log # real time replay
$ for i in *.*; do <$1>; done

> for /f %a in (file.txt) do <>
# (file) can include command e.g. ('dir /B *.txt')
# also: for /f "tokens=1 delims=." %a in () do <>
> for /L %i in (1,1,10); do <%i> done
#variables

variable_name='value' # no spaces!

echo "string string $variable_name string string"
echo "string string ${variable_name} string string" # same

echo "string string `<command>` string string"
result=`<command>`
echo "string string $result string string"

read <variable_name> # user input

# arguments

$n # nth argument

# if

if [[ <a = b> ]]; then # [] is more reliable, but [[]] is better
	<action>
elif [[ <> ]]; then
	<>
else
	<>
fi

-gt -lt -ge -le # greater less than equal

# loops and arguments

for arg in "$@"; do # all arguments
	echo "@arg"
done

# functions

function_name() {
}

function function_name() {
}

function_name <args> # call with args

# running

./<file.sh>

source <file.sh> # keeps variable in shell! also $? quits totally
#!/bin/bash

message="Hello"
echo $message

exit 1 # 1 = okay
exit $?
#!/bin/bash
mkdir zips;
for i in *.*; do
  count=`unzip -l $i | rev | cut -d' ' -f2 | rev | xargs`
  if [ $count -gt 1 ]; then
    filename=`echo $i | rev | cut -d. -f2- | rev`;
    mkdir $filename;
    unzip -d $filename -P infected $i;
  else
    unzip -P infected $i;
  fi;
  mv $i zips;
done