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