vendredi 24 avril 2015

Bash if variable is an integer

im trying to right a if statement in bash that will exit if the variable supplied is not an integer. I will eventually be nesting this if statement within a while loop.

when I do run this I am getting an syntax error.

#!/bin/bash
if [ $f1 != ^[0-9]+$ ]
    then 
                exit 1 
    fi 

Aucun commentaire:

Enregistrer un commentaire