Page 1 of 1

Linux wildcards questions

Posted: Thu Apr 20, 2006 7:44 pm
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?

Posted: Thu Apr 20, 2006 8:16 pm
by redmonkey
Untested but probably something along the lines of....

Code: Select all

ls | grep "\.\(html\?\|pdf\)$"

Posted: Thu Apr 20, 2006 9:43 pm
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 :)

Posted: Fri Apr 21, 2006 2:53 am
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

Posted: Fri Apr 21, 2006 9:40 am
by redmonkey
Yep, my mistake, please excuse my brain fart.

Posted: Fri Apr 21, 2006 10:01 am
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 :)

Posted: Fri Apr 21, 2006 10:03 am
by Chris Corbyn
Never looked at the source but you could get a copy of the linux kernel sources and have a look ;)