3

This is the set of files given:

./20170524/18909-20170524182010-PBS74C2VTTCKBMKGQC7YUVEJ3U-362511-19614379.XFA.SOFS_EDI
./20170524/18909-20170524182009-PBS74C2VTTCKBMKGQC7YUVEJ3U-362514-19614381.XFA.SOFS_EDI
./20170524/18909-20170524182010-PBS74C2VTTCKBMKGQC7YUVEJ3U-362532-19614390.XFA.SOFS_EDI
./20170524/18909-20170524182009-PBS74C2VTTCKBMKGQC7YUVEJ3U-362503-19614371.XFA.SOFS_EDI
./20170524/18909-20170524182009-PBS74C2VTTCKBMKGQC7YUVEJ3U-362506-19614372.XFA.SOFS_EDI

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

8

You can list the files containing that pattern with:

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

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.

cd $TARGET_DIR
ag 'AK9\*[PRE]'

You must log in to answer this question.

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