o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
how to write a bash script checking if there was arguement passed in?
- User
how to write a bash script checking if there was arguement passed in?
- Assistant
To write a Bash script that checks if any arguments were passed to it, you can use the special variable
$#, which holds the number of positional parameters passed to the script. Here's how you can do it:#!/bin/bash if [ $# -eq 0 ]; then echo "No arguments supplied." else echo "Arguments supplied:" echo "$@" fi