Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-02-2006, 05:50 AM   #1
Registered: Nov 2004
Posts: 77

Rep: Reputation: 13
shell script problem

i can't understand the if condition
this is an example but i can't understand what is th $1

$ cat > ispostive
# Script to see whether argument is positive
if test $1 -gt 0
echo "$1 number is positive"

plesae help me

thank you
Old 07-02-2006, 05:58 AM   #2
Registered: Mar 2006
Distribution: RedHat, Slackware, Experimenting with FreeBSD
Posts: 222

Rep: Reputation: 30
The $1 variable refers to the first parameter passed to the script. The if statment just checks if the parameter given is greater than (-gt) 0.

BTW you may want to keep these sorts of questions in the 'newbie' or 'general' section. It is not relevant to networking.
Old 07-02-2006, 06:36 AM   #3
Registered: Nov 2004
Posts: 77

Original Poster
Rep: Reputation: 13
thank you for your help

but stil i dont know where is the first parameter
Old 07-02-2006, 06:41 AM   #4
Registered: Nov 2004
Posts: 77

Original Poster
Rep: Reputation: 13
thank you

i get it

but i have another question

what the diffrent between test statement and [ expr ] statement

thank you very much
Old 07-02-2006, 07:31 AM   #5
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

Rep: Reputation: 31
The answer to all your questions can be found in the bash man pages.

Type: man bash the first pause (bottom of screen -or- : ), type

from then on keep typing n (for next occurance)

Make sure you checkout the chapters labeled:
Positional Parameters


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 problem bondoq Linux - General 3 07-03-2006 07:33 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Problem in shell script Kumar Programming 4 04-27-2004 09:48 AM
shell script problem steltner Linux - General 19 05-18-2003 03:42 PM
shell script problem steltner Programming 0 05-17-2003 04:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration