LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   simple read $a / grep question (https://www.linuxquestions.org/questions/programming-9/simple-read-%24a-grep-question-612023/)

sycamorex 01-08-2008 11:10 AM

simple read $a / grep question
 
Hi,
I wanted to write a simple script to kill a particular program.
My question is as follows:
why does 'ps ax | grep $1' work without any problems
and 'ps ax | grep $number' returns errors with usage or grep?

Code:

#!/bin/bash

E_BADARGS=65
if [ -z "$1" ]    # Check for argument to script.
then
  echo "Usage: `basename $0` program_you_want_to_kill"
  exit $E_BADARGS
fi

echo "Type the number of the process you want to kill: "
ps ax | grep $1
echo " "
echo "No of process you want to kill: "
read $number
echo $number
ps ax | grep $number


I also tried
ps ax | grep `echo $number`
ps ax | grep $(echo $number)

thanks

bigearsbilly 01-08-2008 12:01 PM

should be

read number

sycamorex 01-08-2008 12:07 PM

thanks:) it works fine now


All times are GMT -5. The time now is 03:11 AM.