Linux wildcards questions

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Linux wildcards questions

Post by alex.barylski »

Using ls or whatever, what are the require wildcards for selecting multiple file type(s)

*.pdf, *.htm, *.html

How would I seperate these or is this not allowed?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Untested but probably something along the lines of....

Code: Select all

ls | grep "\.\(html\?\|pdf\)$"
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Grep uses regex...I wanted to know what *wildcards* would be used...not regex :P

Sorry I should have clarified...my bad :)

Thanks anyways though :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hockey wrote:Grep uses regex...I wanted to know what *wildcards* would be used...not regex :P

Sorry I should have clarified...my bad :)

Thanks anyways though :)
ls *.php *.html *.htm
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Yep, my mistake, please excuse my brain fart.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

d11wtq wrote:
Hockey wrote:Grep uses regex...I wanted to know what *wildcards* would be used...not regex :P

Sorry I should have clarified...my bad :)

Thanks anyways though :)
ls *.php *.html *.htm
Cool...

Now I wonder, how does ls execute that task...

Does it carry out each *.xxx separately and join the results after completion or does it parse the whole thing and do it all at once.

Cheers :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Never looked at the source but you could get a copy of the linux kernel sources and have a look ;)
Post Reply