Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-23-2005, 09:31 AM   #1
LQ Newbie
Registered: Feb 2005
Distribution: Suse
Posts: 3

Rep: Reputation: 0
BASH question

If I want to do a line count on all .c and .h files I can do this:

wc -l *.[ch]

*but* how do I add all .mdd files as well?

I tried wc -l *.[ch\"mdd\"]

also wc -- *.[ch&&"mdd"]

but obviously am missing something.

Old 11-23-2005, 10:25 AM   #2
LQ Newbie
Registered: Oct 2005
Distribution: Fedora Core 3
Posts: 20

Rep: Reputation: 0
well... how about :
wc -l *.c *.h *mdd *.<whatever else you want>
Old 11-23-2005, 10:25 AM   #3
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Behind the scenes, bash simply expands the string "*.[ch]" to
all files that match (all .c and all .h files), prior to passing the arguments
to "wc".
So, "wc -l" actually sees a list of all those files as input, not the "*.[ch]" string.
This implies that wc can handle any number of files given as arguments and so you might as well specify multiple filters as well:
wc -l *.[cd] *.mdd
should do the trick...

Old 11-23-2005, 10:39 AM   #4
Senior Member
Registered: Apr 2002
Location: Smithville, TN
Distribution: Slackware
Posts: 1,749

Rep: Reputation: 71
You could also use the cat command.

cat *.cd *.mdd | wc -l

Kinda weird, but I couldn't get the *.[***] to work. I get an error messages saying,
wc: *.[conf]: No such file or directory

Last edited by tangle; 11-23-2005 at 10:42 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about BASH operand Linux - Newbie 2 11-27-2005 10:49 PM
Bash question lnxduck Programming 3 09-30-2005 09:50 AM
bash question? shanenin Linux - Software 1 11-26-2004 01:22 PM
BASH question tpe Linux - Software 6 11-17-2004 09:59 PM
little bash question gplacek Linux - General 2 09-01-2004 01:10 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration