sajad torkamani

Check if the first argument was passed

#!/bin/bash

if [ -z "$1" ]; then
  echo "No first argument was passed."
else
  echo "The first argument is: $1"
fi

Check if any arguments were passed

#!/bin/bash

if [ $# -eq 0 ]; then
  echo "No arguments were passed."
else
  echo "The following arguments were passed: $@"
fi
Tagged: Bash

Leave a comment

Your email address will not be published. Required fields are marked *