pattern

Hi,
How can I restrict to only get the output of lines in which the last pattern consist of 10 or less numbers. :confused:
E.g.

My pattern: 111111111111122222222

But if the pattern is: 111111122222222222222222 then I wouldn't want this line to appear since the 2nd half of the pattern has more than 10 numbers...

Thanks!

You can do that in sed and awk:

sed:

sed -n /'[[:digit:]]\{11,\}/!p' file

awk (gawk):

gawk --posix '!/[[:digit:]]{11,}/' file
grep -v '[[:digit:]]\{11,\}$' infile

I think the OP was asking a different question than has been answered.

The way I read it was:
If a field in an input record, consisting of two groups of numbers (e.g. 1111122222), has less than ten digits in the second numerical group then print the line. Thus 111111111111111333333 is ok, but 11111333333333333 is not. Though one is acceptable, neither of the lines containing these would be printed by the above examples because both fields contain more than ten digits total.

As there is no other description, I've assumed that there are only two different digits that might appear in the last 10 digits of the field. Something like this is needed to determine whether or not the line should be printed:

# assumes first field; change $1 to $n for a different field
awk '
  { 
     ln = length( $1 );
     if( ln < 10 )         # assumes field contains digits; may want to check
     {
        print; 
        next;
     }

     # if the last digit in the field matches the last-10th digit, 
     # then the last numerical set is > 10; print if they dont match
     if( substr( $1, ln, 1) != substr( $1, ln-10, 1) )
        print;
  }'  input-file
# ./justdoit
111111111111122222222
11111111111112
11111111111112222222
1111111111111222
# cat infile
111111111111122222222
11111111111112
11111111111112222222
1111111111111222222222222222222
11111111111112222222222
11111111111112222222222222
111111111111122222222222222222222222222222
1111111111111222
111111111111122222222222222222222222222222
## justdoit ##
#!/bin/bash
 while read -r l
   do
     x=$(echo "$l" | grep -o `echo "$l" | sed 's/.*\(.\)$/\1/'`|wc -l)
      if [ $x -lt 10 ] ; then
       echo "$l"
      fi
   done <infile

Sorry if i got it wrong:

egrep -v '[[:digit:]](0{11,}|1{11,}|2{11,}|3{11,}|4{11,}|5{11,}|6{11,}|7{11,}|8{11,}|9{11,})([^[:digit:]].*)?$' file  # or grep -e
gawk --posix '!/[[:digit:]](0{11,}|1{11,}|2{11,}|3{11,}|4{11,}|5{11,}|6{11,}|7{11,}|8{11,}|9{11,})([^[:digit:]].*)?$/' file

Perhaps $ is no longer needed and [:digit:] can be 0-9. It's your option.