#!/bin/bash
# Parse command line arguments
while getopts "f:" opt; do
case $opt in
f)
file_name="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# Check if the file_name is provided, exit if not
if [ -z "$file_name" ]; then
echo "Error: File name not provided. Use -f option to specify the file name."
exit 1
fi
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme