regex - grep ignore characters in the pattern -
the pattern comes variable of length 14. string pattern grep. text file has lines contain 13 characters each.
for example, pattern of length 14 is
pattern =   58244804671021 and text file contains
3823480467102 4724470467102 how can make grep ignore last char in pattern?
suppose pattern in $pattern , using bash, can do
grep ${pattern%?} file to remove last character variable.
you can use cut character 1 13:
grep $(echo "$pattern" | cut -c 1-13 -) file or better in bash , ksh here-string
grep $(cut -c 1-13 <<<$pattern) file 
Comments
Post a Comment