LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 11-23-2005, 08:31 AM   #1
robscott
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.

Cheers.
 
Old 11-23-2005, 09:25 AM   #2
raseel
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, 09:25 AM   #3
timmeke
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...

Tim
 
Old 11-23-2005, 09:39 AM   #4
tangle
Senior Member
 
Registered: Apr 2002
Location: Smithville, TN
Distribution: Slackware
Posts: 1,745

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 09:42 AM.
 
  


Reply


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 09:49 PM
Bash question lnxduck Programming 3 09-30-2005 08:50 AM
bash question? shanenin Linux - Software 1 11-26-2004 12:22 PM
BASH question tpe Linux - Software 6 11-17-2004 08:59 PM
little bash question gplacek Linux - General 2 09-01-2004 12:10 PM


All times are GMT -5. The time now is 04:52 AM.

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