What is "test"? How it is used in shell scripting?

Answers were Sorted based on User's Feedback



What is "test"? How it is used in shell scripting?..

Answer / madhavi

test is used to validate an expression in shell script.
for ex:in if loop ,is used as follows
if test a > b
{
#some statements
}
fi
instead of
if [ a > b ]
{
#some statements
}
fi

Is This Answer Correct ?    3 Yes 0 No

What is "test"? How it is used in shell scripting?..

Answer / swaroopa

The test command is particularly useful in this context
allowing a variety of conditions to be checked for. There
are two equivalent syntaxes.

test expression

and
[ expression ]

The following simple example will list all the
subdirectories of the current directory.


for i in *
do
if [ -d $i ]
then
echo $i
fi
done

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Shell Script Interview Questions

How to make userdefined variables to available for all other shells?

4 Answers  


What does echo mean in scripting?

0 Answers  


Why is a script important?

0 Answers  


write a shell program to check wheather a given string is pallindrome or not?

4 Answers  


When should shell programming/scripting not be used?

0 Answers  


In which variable prompt value is stored?

2 Answers  


I have 2 files and I want to print the records which are common to both.

0 Answers  


Can shell script run on windows?

0 Answers  


In shell scripting if text is surrounded by single quotes what does it denotes?

3 Answers  


‎What is a shell? · ‎Types of shell · ‎what is shell scripting?

0 Answers  


how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?

0 Answers  


What are the different types of variables used in shell script?

0 Answers  


Categories