Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Archives for if then else

January 15, 2019

Check Argument in Bash

How to check for an argument in a script in Bash.

if [ -z "$1" ] ; then
  echo "there are no arguments"
else
  echo "there is an argument"
fi

if [ -z "$1" ] ; then echo "there are no arguments" else echo "there is an argument" fi

  • Cloud
  • Linux
  • Git

Copyright © 2012–2021