LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-02-2006, 05:50 AM   #1
bondoq
Member
 
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
#!/bin/sh
#
# Script to see whether argument is positive
#
if test $1 -gt 0
then
echo "$1 number is positive"
fi

plesae help me

thank you
 
Old 07-02-2006, 05:58 AM   #2
SlackDaemon
Member
 
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
bondoq
Member
 
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
bondoq
Member
 
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
scowles
Member
 
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

...at the first pause (bottom of screen -or- : ), type
/expr

from then on keep typing n (for next occurance)

Make sure you checkout the chapters labeled:
Positional Parameters
ARITHMETIC EVALUATION
CONDITIONAL EXPRESSIONS
 
  


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 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


All times are GMT -5. The time now is 02:33 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