LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-30-2004, 03:53 AM   #1
racer_mec
LQ Newbie
 
Registered: Dec 2004
Posts: 11

Rep: Reputation: 0
Unhappy shell script


hi,
am a beginner to shell script.i want to know whether any commands are there which will show the no. files with a particular extension.also suppose we count no of java files then can we calculate the no. ofutil packages imported..
regards
racer
 
Old 12-30-2004, 05:16 AM   #2
Gag Halfrunt
LQ Newbie
 
Registered: Nov 2004
Distribution: Mandrake/Knoppix
Posts: 24

Rep: Reputation: 15
Similarly, I'd be interested in finding out how to make a script that displays the line-count of a text file.
 
Old 12-30-2004, 05:39 AM   #3
racer_mec
LQ Newbie
 
Registered: Dec 2004
Posts: 11

Original Poster
Rep: Reputation: 0
to find the number of line you can use wc
 
Old 12-30-2004, 05:59 AM   #4
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
let's say the extension is .exe
we would issue this command to count them
Code:
$ ls | grep *.exe | wc
 
Old 12-30-2004, 06:18 AM   #5
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Quote:
Originally posted by Gag Halfrunt
Similarly, I'd be interested in finding out how to make a script that displays the line-count of a text file.
Code:
$ wc FILENAME
wc outputs data in the following manner:

word, line, character, and byte count
 
Old 12-30-2004, 06:58 AM   #6
racer_mec
LQ Newbie
 
Registered: Dec 2004
Posts: 11

Original Poster
Rep: Reputation: 0
but suppose there are some java files then how can i count the no. of java files that imports java.util.*
i have colected all the4 filenames in a file can i do a loop and check teh each individual files for the import util with grep
regards
racer
 
Old 12-30-2004, 07:20 AM   #7
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
this should work, if not, a shell script incorporating for should:
Code:
$ ls | xargs head | grep java.util.\* | wc
 
Old 12-30-2004, 07:47 AM   #8
racer_mec
LQ Newbie
 
Registered: Dec 2004
Posts: 11

Original Poster
Rep: Reputation: 0
its not working....i got the java paths stored in a file java_files can i execute the grep for each path
 
  


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 07:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-12-2005 12:08 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM


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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration