• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Check Argument in Bash

January 15, 2019 by Ulysses

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

Filed Under: Linux Tagged With: argument, check, if then else

Subscribe via email.

  • Home
  • About
  • Archives

Copyright © 2012–2022