Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small Shell Scripts

Status
Not open for further replies.

Kinl

Programmer
Mar 19, 2001
168
US
HI guys,

I'm not usually a UNIX scripter, but I have a few things that I need to get done here. I've looked at a few books, and read a few websites but I cant seem to help myself out. I'm trying to write some scripts, and these two are giving me problems.

1. I need to write a shell script that attempts to output all of the running instances of the program, displaying name of the user, terminal, pid, and start time when the program was first run.

I know this has something to do with the "ps" command. I can get it so I can see how many instances are running by using this :

ps -C bash #this will show me all the instances of
#the bash shell running on the machine.

I cant get it to show me the other info, such as the username.

Problem #2.
I need to find out how many different file types there are in a a given directory (and then go thru all of its subdirectories).. So if I have multiple directories in on main directory, I need to get all the types of file names.
I know this has something to do with
ls -lR
Then I must also find the directory structure. How do I do that?


Thanx for any help!!

-shorty
 
Enter "man ps" from the command line, and you will see a list of all the variables and output options associated with "ps". (if you are not familiar with "man", that means Manual, in Unix, and it outputs the manual for the specified item using the standard "less" pager, which means you can keep hitting the enter key, PageUp, PageDown, etc... keys to scroll up and down. Use "q" to quit.)

If you are not familiar with "less", there is actually a home page for that very essential Unix program:
For your second question, enter "man ls". You will also probably want to read about a couple of other Unix utilities such as "find", "locate", and the all-important "grep".

If all of these are a complete mystery to you, you will want to spend some time at:


HTH ;-)
 
Hi,

Well for the first one you can do :

ps -aux | grep httpd

(where httpd is what you're looking for)

Rgds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top