I never had to do it before but there is always the first time. I wrote a
script in which I convert data into ASCII comma delimited file. It's quite
long so I won't post it here unless requested. As always is the case with
projects like this, clients always come up with the strangest ideas. In any
case, I have to check if a field from a record contains a string of numbers
only and if it doesn't, I would replace it with a different field.
I came up with this:
case $myVariable in
[0-9][0-9][0-9][0-9] ) # in reality there are 7 digits I have to check
I have quickly come to learn that this approach will become very cumbersome
very fast. Hence the question. Can I use a regular expression in a
conditional like this:
if [ "$myVariable" != '[0-9][0-9][0-9][0-9]' ]; then
It doesn't quite work for me so obviously there is a flaw in my thinking.
So is it possible and so, how would I do it?