LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 03-07-2002, 10:17 AM   #1
vicsharps
LQ Newbie
 
Registered: Mar 2002
Location: Maryland
Posts: 1

Rep: Reputation: 0
Need Help with Shell Scripts!!!!!!!!!!!


I have never used Linux or Unix before and have been asked to try to write a shell script given the real UNIX person found a better job. But anyway can anyone give me any help. Here is what they are asking for:

The want the script to run a "ps" command. The usage of the script is ps [search string] [ps options]

They want it to run with from 0 to 2 arguments (whatever they are).


1. no arguments ps -ef | less

2. 1 argument ps -el and pipe to grep (whatever that is)

3. 2 arguments ps-el to grep and output to less.

Can someone help me with this. I will be happy to help with any networking questions you may have (roiuters, switches, etc..)


Victor
 
Old 03-07-2002, 10:33 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
i'm sorry, i can't really see a real question anywhere, can you be a bit more specific? you can assume everyone is fluent with ps, less, grep etc...
 
Old 03-07-2002, 01:25 PM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
If I understand what you are trying to ask then your script should look like this:

#!/bin/sh

if [ $# = 2 ]
then
ps -ef | grep $1 | less
elif [ $# = 1 ]
then
ps -ef | grep $1
else
ps -ef | less
fi
 
Old 03-07-2002, 09:05 PM   #4
Aussie
Senior Member
 
Registered: Sep 2001
Location: Brisvegas, Antipodes
Distribution: Slackware
Posts: 4,590

Rep: Reputation: 58
Have a read of the Bash-Prog-Intro-HOWTO.
 
  


Reply



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
Need help with shell scripts thorney Linux - Newbie 4 11-27-2005 11:18 PM
Shell Scripts benwy Linux - Software 1 06-09-2003 02:58 AM
Shell scripts anon227 Linux - Software 1 01-03-2003 03:11 PM
shell scripts nautilus_1987 Linux - General 3 08-30-2002 03:12 AM
shell scripts gui10 Programming 10 10-28-2001 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:57 PM.

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
Open Source Consulting | Domain Registration