Bash error "command not found"

I’m having an issue with this “command not found” error (see .bash script text below comment). This is a script to simply test alphanumeric input.

I have found some partial solutions pointing to missing information in the $PATH file but no solid answers. I’m currently using on Mac OS X along with other working .bash scripts. Please help thanks.


_____

#!/bin/bash

# validAlphaNum – Ensures input consists of only alphabetical and numeric characters

validAlphaNum()
{

#error message "command not found" occurred on next line
$compressed="$(echo $1 | sed 's/^[[:alnum:]]//g')"

if [ “$compressed” != “$input” ] ; then
  return 1
else
  return 0
fi
}

echo “Enter input: “
read $input

if ! validAlphaNum “$input” ; then
  echo “Your input must consist of only letters and numbers.” >&2
  exit 1
else
  echo “Input is valid.”
fi

exit 0

Open in new window

Tech_20Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
compressed="$(echo $1 | sed 's/^[[:alnum:]]//g')"

read input
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scot HalvorsenCommented:
What "ozo" is trying to say is that your use of variables was incorrect on these two lines.
You "define" variables w/o the dollar sign.
0
Tech_20Author Commented:
@ozo nailed the solution, @shalvors reiterated it with more effective comments
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.