Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex help multiple pattern extensions 1

Status
Not open for further replies.

rigstars2

Instructor
Dec 18, 2011
64
US
Hello,

I can't seem to get my regex right to print out bot the .xml and .zip file. I've been working on this for hours. Can someone please assist this old timer. Thanks in advance. Doing this on a mac os x system if that matters any.

find . -regex "./DC18B[0-9]*\(.zip|.xml\)" -print
find . -regex "./DC18B[0-9]*\./(zip\|xml/)" -print

DC18B20181130111.xml
DC18B20181130111.zip
 
Try this
[pre]
$ find . -regextype posix-extended -regex '.*/DC18B[0-9]+\.(xml|zip)'
./progtest/DC18B20181130111.xml
[/pre]

--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Salem,

Appears mac os doesn't support -regextype

find: -regextype: unknown primary or operator
------------
Is it not possible to find to both .xml and .zip at same time? I'm able to
find 1 extension at a time if I break them into 2 lines of code.

feed="$(find . -regex "./SC32A[0-9]*.xml")"
feed="$(find . -regex "./SC32A[0-9]*.zip")"

Thanks in advance.
 
this appears to work though, not regex but will do

feed="$(find . -type f \( -name "*.zip" -o -name "*.xml" \))"

Thanks for your ideas Salem. Much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top