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.



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


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

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

echo “Enter input: “
read $input

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

exit 0

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

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

read input

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.
Tech_20Author Commented:
@ozo nailed the solution, @shalvors reiterated it with more effective comments
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.