Some notes about your script:
1) you don't really need the assignment
since you can use $@ directly in the expression inside the if/then construct.
2) you forgot to put a $ sign before the variable name inside the expression:
Code:
if [ $input == .txt ]
without that you just evaluate the equivalence between two strings, which is obviously always false.
3) if using bash version 3 you can try the operator for
Regular Expression Match so that your script will look like
Code:
#!/bin/bash
if [[ $@ =~ [.]txt ]]
then
echo yes
else
echo no
fi