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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the disadvantages of shell scripting?

839


Is powershell a bash?

756


What is the use of .sh file?

812


Calculate a real number calculation directly from the terminal and not any shell script.

905


How to print the first array element?

778


is this growing field and what is average package in this?

2072


What is a shell in operating system?

778


Write down the syntax for all the loops in shell scripting.

864


Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

1183


What does $@ mean bash?

832


What is the lifespan of a variable inside a shell script?

1354


how will you find the total disk space used by a specific user?

782


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

932


What is mac default shell?

800


What is the difference between grep and egrep?

824