INPUT:  $ echo -e 'AAAART5530408XXXX\nAAAAZE6530408XXXX\nAAAART12345678XXXX'AAAART5530408XXXXAAAAZE6530408XXXXAAAART12345678XXXX$OUTPUT: $ echo -e 'AAAART5530408XXXX\nAAAAZE6530408XXXX\nAAAART12345678XXXX' | sed -e 's/\(AAAA[A-Z]\{2\}[0-9]\{7\}\)XXXX/\n\1/g'AAAART5530408AAAAZE6530408AAAART12345678XXXX$   How can I extend the: sed -e 's/\(AAAA[A-Z]\{2\}[0-9]\{7\}\)XXXX/\n\1/g'sed oneliner, so that it would optionally accept sed -e 's/\(AAAA[A-Z]\{2\}[0-9]\{8\}\)XXXX/\n\1/g'8 numbers too? (not just 7) Is it possible with only 1 sed?
How can I update this sed oneliner?
sed
The \{7\} construct is a simple case of the \{m,n\} for match at least m and at most n, in your case it'll be:sed -e 's/\(AAAA[A-Z]\{2\}[0-9]\{7,8\}\)XXXX/\n\1/g'Perhaps a simple:sed -s 's/XXXX//g'is enough in your case?