shell scripting error

i am trying to work on a simple shell script as

#!/bin/bash
filename = $2
if [ "$1" = "-cat" ]; then
echo " Displaying the Content of the file:"
filename = $2
cat filename
else
if [ "$1" = "-ls"]; then
echo "Displaying directory listing:"
ls -l filename
else
echo " Commands not correct:"
fi
done

it shows the error
line 14: syntax error near unexpected token 'done'
line 14: 'done'
i am using bash shell in ubantu..

thank you and regards

edit by bakunin: please use CODE-Tags when posting code. It greatly enhances readability and it cheers up the venerable cfajohnson to no end. I have inserted them now for you.

for each if statement should end with a fi

you are missing with a fi.

Please put code inside

 tags.



#!/bin/bash
filename = $2

[/quote]

[indent]
When posting code, please do not retype it; insert the script file or cut and paste the code. The previous line would have given you an error if that is what you actually were running.

filename=$2

Redundant, with the same error as above.

Do you mean:

cat "$filename"

Do you mean:

ls -l "$filename"

You don't have a do to close with done.

This lends itself to a "case" statement.

#!/bin/bash
action="$1"
filename="$2"
#
case "${action}" in
        "-cat")
               echo "Displaying the Content of the file:"
               cat "${filename}"
               ;;
        "-ls")
               echo "Displaying directory listing:" 
               ls -l "${filename}"
               ;;
        *)
               echo "Commands not correct:"
               echo "Usage scriptname [-ls | -cat] filename"
               ;;
esac