Кто-нибудь может мне помочь, пожалуйста?я написал скрипт и в моем скрипте я использовал GETOPTS для создания опций, но он не работает
он имел какую-то ошибку, и я проверял это в shellcheck.net и исправлял их, но он не работает
#!/bin/bash
while getopts 'n:c2rFt' option; do
case "$option" in
n) export Field="$OPTARG"
;;
c) #Question 1
cat "$1" | awk '{print $1}' | sort | uniq -c | sort -nrk 1,1 > file1
awk 'NR=="$Field" {print}' file1
;;
2) #Question 2
cat "$1" | awk '{ if($9 == 200) print $1,$9 }' | sort | uniq -c | sort -nrk 1,1 > file1
awk 'NR=="$Field" {print}' file1
;;
r) #Question 3
cat "$1" | awk '{print $1,$9}' | sort | uniq -c | sort -nrk 1,1 > file1
awk 'NR=="$Field" {print}' file1
;;
F) #Question 4
cat "$1" | awk '{if($9 >= 400 && $9 <= 451)} {print $1,$9}' | sort | uniq -c | sort -nrk 1,1 > file1
awk 'NR=="$Field" {print}' file1
;;
t) #Question 5
cat "$1" | awk '{print $1,$10}' | sort | uniq -c | sort -nrk 3,3 > file1
awk 'NR=="$Field" {print}' file1
;;
?)
echo "You used wrong option"
echo "USAGE: log_sum.sh [-n N] (-c|-2|-r|-F|-t|-f) <filename>"
echo " -n: Limit the number of results to N"
echo " -c: shows th IP address makes the most number of connection attempts"
echo " -2: shows th most number of seccessful attempts "
echo " -r: shows th most common result codes and their IP addresses"
echo " -F: shows the most common result codes that indicate failure"
echo " -t: shows the IP addresses that get the most bytes sent to them"
exit 1
;;
esac
done