Reputation: 47
I received an error stating: "line 32 (final line): syntax error: unexpected end of file". I couldn't find the source of the error.
First input for the script: Input file name
Second input for the script: Employee name
Second column of the input file: Employee name
Fifth column of the input file: Salary
Sixth column of the input file: Date of joining
# Check whether or not the command has two arguments
if [ $# -ne 2 ]; then
echo "You must enter 2 arguments!\n"
echo "Application is now exiting..."
exit
fi
# Check whether or not the employee name supplied by the user is available in the input file
awk -v employee_name=$2 -v is_employee_available=0 -v year=0 -v new_salary=0
'BEGIN{FS="|"}
{
if(employee_name == $2) {
is_employee_available=1;
year=strtonum(substr($6,8,11));
if(year==1990)
new_salary=$5+2000;
else if(year==1991)
new_salary=$5+1500;
else if(year==1992)
new_salary=$5+1000;
else if(year>1992)
new_salary=$5+500;
else
print "Invalid year of joining!";
}
}
END
{
if(is_employee_available==0)
print "The provided employee does not exist!";
}' $1
Thank you.
Upvotes: 1
Views: 353
Reputation: 16997
awk -v employee_name=$2 -v is_employee_available=0 -v year=0 -v new_salary=0
'BEGIN{FS="|"}
^
Because of this
To
awk -v employee_name="$2" -v is_employee_available="0" -v year="0" -v new_salary="0" '
BEGIN{FS="|"}
OR
awk -v employee_name="$2" -v is_employee_available="0" -v year="0" -v new_salary="0" \
\
'BEGIN{FS="|"}
and
(with this you will get : END blocks must have an action part)
END
{
To
END{
OR
END\
\
{
and ( quoting is good practice )
}' $1
To
}' "$1"
Upvotes: 1