Home About BC DR HA Support Training Download
You are here: Home/ Training/ Unix-Bourne-Shell/ Please Login or Register

-
Current Location
-

js
  Training
    Unix-Bourne-Shell



-
 Mt Xia Inc.
-
BOOK:Advanced Shell Scripting



 Join our LinkedIn Group
AIX Advanced Technical Experts
Contract Opportunities

www.LinkedIn.com
-
 Train By Tweet
Training courses Tweet By Tweet
Various Subjects and Products
TrainByTweet.com


AIX Admin Methodology
Global Consolidation Project
All AIX admins should join
www.aixexpert.com
-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


AIX FREE DEMO UNIX
Automated AIX Deployment
Reduce your DC costs

www.siteox.com

LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com

-

Manual: test(1)

-

Please contact or Mt Xia for assistance with all your shell programming needs.


test(1)								      test(1)



NAME
  test,	[  - Evaluates conditional expressions

SYNOPSIS

  test expression

  [ expression ]

DESCRIPTION

  The test command evaluates an	expression constructed of functions and
  operators.  If the value of expression is true, test returns an exit value
  of 0 (zero); otherwise, it returns a nonzero (false) exit value.  The	test
  command also returns a nonzero exit value if there are no arguments.

  The alternate	form of	the command surrounds expression with [	] (brackets).
  When you use this form, you must surround the	brackets with spaces.

  The test Expressions

  All of the listed functions and operators are	separate arguments to test.

  The following	functions are used to construct	expression:

  -r file
      TRUE if file exists and has read permission.

  -w file
      TRUE if file exists and has write	permission.

  -x file
      TRUE if file exists and has execute permission.

  -f file
      TRUE if file exists and is a regular file.

  -d file
      TRUE if file exists and is a directory.

  -e file
      TRUE if file exists.

  -c file
      TRUE if file exists and is a character-special file.

  -b file
      TRUE if file exists and is a block-special file.

  -p file
      TRUE if file exists and is a named pipe (FIFO).

  -h file
      TRUE if file exists and is a soft	link.  Synonym for -L.

  -L file
      TRUE if file exists and is a soft	link.  Synonym for -h.

  -u file
      TRUE if file exists and its set-user ID bit is set.

  -g file
      TRUE if file exists and its set-group ID bit is set.

  -k file
      TRUE if file exists and its sticky bit is	set.

  -s file
      TRUE if file exists and has a size greater than 0	(zero).

  -t [file_descriptor]
      TRUE if the open file with file descriptor number	file_descriptor	(1 by
      default) is associated with a terminal device.

  -z string1
      TRUE if the length of string1 is 0 (zero).

  -n string1
      TRUE if the length of string1 is nonzero.

  string1 = string2
      TRUE if string1 and string2 are identical.

  string1 and string2 are not identical.

  string1 is not the null string.

  number1 -eq number2
      TRUE if the integers number1 and number2 are algebraically equal.	 Any
      of the comparisons -ne, -gt, -ge,	-lt, and -le can be used in place of
      -eq.

  The listed functions can be combined with the	following operators:

  !   Unary negation operator.

  -a  Binary AND operator.

  -o  Binary OR	operator (-a has higher	precedence than	-o).

  \( expression	\)
      Parentheses for grouping.

EXAMPLES

   1.  To test whether a file exists and is not	empty, enter:
	    if test ! -s "$1"
	    then
		    echo $1 does not exist or is empty.
	    fi


       If the file specified by	the first positional parameter to the shell
       procedure does not exist, this displays an error	message.  If $1
       exists, it displays nothing.  Note that there must be a space between
       -s and the filename.

       The double quotes around	$1 ensure that the test	will work properly
       even if the value of $1 is the empty string.  If	the double quotes are
       omitted and $1 is the empty string, test	displays the error message
       test: parameter expected.

   2.  To do a complex comparison, enter:
	    if [ $# -lt	2  -o  ! -s "$1" ]
	    then
		    exit
	    fi


       If the shell procedure was given	fewer than two positional parameters
       or the file specified by	$1 does	not exist, then	this exits the shell
       procedure.  The special shell variable $# represents the	number of
       positional parameters entered on	the command line that started this
       shell procedure.

EXIT VALUES

  The test command evaluates expression	and, if	its value is TRUE, returns an
  exit value of	0; otherwise, it returns a nonzero (FALSE) exit	value; the
  test command also returns a nonzero exit value if there are no arguments.

RELATED	INFORMATION

  Commands:  csh(1), find(1), ksh(1), sh(1).

-
Manual: test(1)
-
 

Introduction
Table of Contents
Chapter 1
Chapter 2a
Chapter 2b
Chapter 3
Chapter 4a
Chapter 4b
Chapter 5a
Chapter 5b
Chapter 6a
Chapter 6b
Chapter 6c
Chapter 7a
Chapter 7b
Chapter 8
Chapter 9a
Chapter 9b
Manual: ar(1)
Manual: cb(1)
Manual: cc(1)
Manual: expr(1)
Manual: f77(1)
Manual: ftp(1)
Manual: ksh(1)
Manual: lint(1)
Manual: sh(1)
Manual: test(1)
Manual: time(1)


AIX FREE DEMO UNIX
Automated AIX Deployment
Reduce your DC costs

www.siteox.com

LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com