[lug] sed question - specifying alternatives

David L. Anselmi anselmi at anselmi.us
Fri Feb 3 15:52:33 MST 2006


Bill Thoen wrote:
> I'm trying to get sed to recognize two types of records in a file.
> Basically, I don't care what's in th efirst 11 places, but after that I
> want any record where 001 or 015 are in the 12th through 15th positions.
> When I try:
> 
> sed -n -e '/^.\{11\}(001\|015)/p' tblDesc.txt

You have to escape the parens too.

(Extended regexps might be easier for something like this, if you figure 
out how to make sed use them.  I'm sure it's easy, just didn't look.)

Dave



More information about the LUG mailing list