This is the set of files given:


This is what's inside in every file. They have different AK9 segments. Like AK9*A, AK9*P, AK9*R or AK9*E.

ISA*00*          *00*          *SS*252649841464SS *01*12564486M      *102453*1254*U*025402*21651681320*0*S*>~SS*SS*5648408456SS*0150158011S*20170228*1921*020151018*X*0210540~SS*997*008609070~AK1*SH*107405~AK2*856*362518~AK5*A~AK9*A*1*1*1~SE*6*008609070~GE*1*008604488~IEA*1*008602662~

I'm looking for a file with this pattern:

AK9*P or AK9*R or AK9*E

2 Answers 2


You can list the files containing that pattern with:

grep 'AK9\*[PRE]' -l ./20170524/*

You could also use the silver searcher or ag, with the regex in @StephenRauch's answer. This gives you the ability to do it across more files if it becomes necessary.

ag 'AK9\*[PRE]'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .