I am probe in Unix.
I want to know what does this mean?
type ant 1>/dev/null
moduledir=`dirname $0`
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
typecommand (under UNIX, don’t confuse this with MS-DOS/Windows’CMD.EXE) will show you how a command would be interpreted if executed.Using
typethat way, would print an error message (e.g.ant not found) should theantcommand not be found/executable. As others have said, the1>/dev/null(or simply>/dev/null) redirects messages written to the standard output by that command to “nowhere”, i.e. they will not be printed on the terminal / console. Messages written to the standard error stream would/will still occur. It looks like, that line was meant to check for whetherantcould be executed/found, however a respective check to (say) abort the script was not provided, it could like this (depending on your shell, but it looks like a bourne shell flavor anyway):Another note: with
bashthe type command never writes any output to the standard error stream, i.e. even the message... not foundgets written to standard output. So the command, as it stands, does never output anything, even in the case of an error (in which the message seems sensible to display, given that this fragment is used as a check anyway).Finally, the
line stores the directory name of the currently executing script in the variable
moduledir. You could later reference it like$moduledir, for example:echo "The directory is: $moduledir.Frankly, the two statements, isolated as they are in your question make little sense. While syntax-wise correct, they bear no deeper meaning so one can only speculate what they were ment for. You might want to consider asking another question about what you are actually trying to achieve, rather than just posting (arbitrary) syntax.