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 CREATE 10 USERS IN UNIX(HP-UX) USING SHELL SHELL SCRIPT?

3 Answers   Patni,


Explore about environment variables?

0 Answers  


i have 2 tables 4 colums table 1 respective values a1 6, a2 8,a3 9,a4 14 & table 2 respective values a1 6, a2 8, a3 9, a4 12. if compare 2 tables 3 colums values same then 4th column values 1)Qes diff >5 then (5 * diff value ) 2)Qes diff <5 the 5 3)Qes diff 5 then 5 print respective values..

0 Answers   Tech Mahindra,


What is wc in shell script?

0 Answers  


How do I run a shell script in powershell?

0 Answers  






What is the difference between a shell variable that is exported and the one that is not exported?

6 Answers  


Is powershell a language?

0 Answers  


How do you find out What is your shell?

0 Answers  


What is meant by $1 in shell script?

0 Answers  


What is shell environment?

0 Answers  


State the advantages of shell scripting?

0 Answers  


What is awk script?

0 Answers  


Categories