Why I have a integer expression expected error with this:
at=`echo $1 | grep -q "@"`
if [ $at -ne 0 ]; then
echo "blabla"
else
echo "bloblo"
fi
$at is set, and the test working fine outside the script
When testing the result of grep -q, you want to test $? not the output of grep, which will be empty
at=$(echo "$1" | grep -q "@")
if [ $? -ne 0 ]; then ...
or simply
if echo "$1" | grep -q "@"; then ...
or, more bash-ly
if grep -q "@" <<< "$1"; then ...
or, without calling grep:
if [[ "$1" == *@* ]]; then ...
or
case "$1" in
*@*) echo "match" ;;
*) echo "no match" ;;
esac
-ne is for comparing integers. Use != to compare strings.