What is "test"? How it is used in shell scripting?
Answers were Sorted based on User's Feedback
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 |
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 |
What is the first line of a shell script called?
how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
What does debug script mean?
what is info area how many types?
How do I save a powershell script?
What is a batch file used for?
What shell is bin sh?
how to delete all the files with extension .dat rom a directory tree from root to third level in a single unix command?
Write a shell script in Linux to shift all characters in a file forward by five characters. (Thus “a” becomes “f’”).
2 Answers Ignou, Tripura Info,
How to change our default shell?
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); }
Write down the syntax for all the loops in shell scripting.