Advertisement
metalx1000

BASH Shift through Arguments

Mar 15th, 2019
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.18 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #check for argument
  4. if [ $# -lt 1 ]; then
  5.   echo "Usage: $0 name(s)"
  6.   exit 1
  7. fi
  8.  
  9. #loop through all arguments
  10. while (($#)); do
  11.   echo "Hello $1"
  12.   shift
  13. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement