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 replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }

0 Answers   Wipro,


Write a shell script that adds two numbers if provided as the command line argument and if the two numbers are not entered throws an error message.

0 Answers  


What is sed in shell script?

0 Answers  


What is bash eval?

0 Answers  


Is shell scripting a language?

0 Answers  






give me some website where i can get unix and testing meterials

1 Answers  


What is a shell environment?

0 Answers  


write a shell script to check the failed jobs?

0 Answers   Wells Fargo,


How to check if a directory exists?

0 Answers  


Create a bash shell script that reads a line from the user consisting of 5 words and then prints them out in reverse order. Name this script "reverse.sh"

1 Answers  


What is a scripting language simple definition?

0 Answers  


How will you emulate wc –l using awk?

0 Answers  


Categories