regex

hi frnds
i m having prb while matching a numerical num...

[0-9]+ is not working for me... ( ?? )

so i m achieving the criteria with [0-9]\{1,\} ( pl suggest if i m wrong )

nw the prb is.. i dont want to match the number with all zeros in it..
eg 00000 or 0000000 etc etc...

pl help..

Thanks..
Anchal.

What shell are you using? Are these files? Are these patterns in a file? Are you using grep, awk, perl, sed, bash, tcsh?

hi
i am working on bash shell on linux box.
i am applying this pattern to search for files with some specific format...

pl help

Refer to the man page section on "Pattern Matching", otherwise known in Shell parlance as "fileglob". The [0-9] is right, but "+" doesn't work here. To match a non-zero digit followed by more digits, you need:

shopt -s nullglob
echo [1-9][0-9]*

If you can have leading zeros, but you don't want to match one with ONLY 0's, then you can do:

shopt -s nullglob
echo [1-9][0-9]*  [0-9]*[1-9][0-9]*  [0-9]*[1-9]

This last one matches : (1) any number starting with a non-zero, AND (2) any number with a non-zero in the middle, AND (3) any number ending with a non-zero.

The shopt -s nullglob ensures that if the expression does not match, you get the empty string (instead of the pattern itself).