Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 01-07-2005, 10:46 AM   #1
Registered: Aug 2003
Location: NY
Distribution: RH9, RH8, Slack, Vector
Posts: 497

Rep: Reputation: 31
Grep Help

Believe it or not, I have been using linux for a couple years and have never used Grep before. So, I am really unfamiliar.

Ok, I need to find the total lines of code in a directory and sub-directories


but, I also have .gif's and other types of media along with the php.

So far I have
grep -r -i -c [abcdefghijklmnopqrstuvwxyz1234567890{}] /var/www/html

Which give me a rough estimate, but I know there has to be a way to do it a.) easier and b.) more accurately.

Thanks in advance.
Old 01-07-2005, 11:03 AM   #2
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Ironically, no grep required. I think this would do.
find -type f -iregex .*\.php$ -exec cat {} \; | wc
Old 01-07-2005, 11:12 AM   #3
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Also try ...
cat *.php | sort | wc -l
Old 01-07-2005, 12:38 PM   #4
Registered: Aug 2003
Location: NY
Distribution: RH9, RH8, Slack, Vector
Posts: 497

Original Poster
Rep: Reputation: 31
thanks alot,I knew there was something I was missging.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
grep ?? can grep us variables? DaFrEQ Linux - Software 4 09-14-2005 12:22 PM
help on grep!!!! sanjith11 Programming 5 01-20-2005 05:43 PM
What does rpm -qa |grep th* (as compared to rpm -qa |grep th) display? davidas Linux - Newbie 2 03-18-2004 01:35 AM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 03:11 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10: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
Open Source Consulting | Domain Registration