Thursday, January 14, 2016

Bash Script

Bash Script arguments are as follows:

  1. First Argument: $1
  2. Second Argument: $2
  3. Third Argument: $3

Example:

  • Terminal# ./script alpha bravo charlie
  • Variables: $1=='alpha'; $2=='bravo'; $3=='charlie'

Script Example

#!/bin/bash
echo "the $1 eats a $2 every time there is a $3"
echo "bye =)"

  • Terminal# ./script dog bone moose
  • Output: the dog eats a bone every time there is a moose
    bye =)



Reference

http://how-to.wikia.com/wiki/How_to_read_command_line_arguments_in_a_bash_script

No comments:

Post a Comment