What command is being used wrongly in this script?

1

When I run the script, I get the error message that grep was used wrongly, what's wrong with the script?

Code:

#!/bin/bash

read $ALVO
RESULTADO=$(ps -A | grep $ALVO)
$RESULTADO kill -KILL 

Error message:

sublime
Uso: grep [OPÇÃO]... PADRÃO [ARQUIVO]...
Experimente "grep --help" para mais informações.
kill: uso: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... ou kill -l [sigspec]

Note: Here the sublime was a test

    
asked by anonymous 12.03.2017 / 07:19

1 answer

1

Since the value ALVO has not yet been assigned a value, you can not reference it with "$". Since the variable is empty when using it with the command grep an error is returned.

#!/bin/bash
read ALVO
RESULTADO=$(ps -A | grep $ALVO)
$RESULTADO kill -KILL 
    
15.03.2017 / 12:27