[[ -e $filename ]] - which man page to refer to these options

What does this do:

f{
        local logfile=$1
	[[ -z $logfile ]] && logfile=$AMS_LOGFILE

	echo -e "--"
}

Can someone please guide me what does
a) local variable do
b) -z option stands for what?
c) what other options are there (like -n, or -e, .., which man page do i refer to go through these options?
d) what does that whole line checks for and do? [[ -z $logfile ]] && logfile=$AMS_LOGFILE

thanks
Amit

Hello AKS_Techie,

A warm Welcome to UNIX.com.

Try man test once in your box and you will get a descriptive answer for all options there.
Go through it and do share your learning with us too, show us your efforts.

Thanks,
R. Singh

Hi Ravinder,
Sorry, but I have to disagree with you here. If the command was:

	[ -z $logfile ] && logfile=$AMS_LOGFILE

or:

	test -z $logfile && logfile=$AMS_LOGFILE

or more correctly if written using test :

	[ -z "$logfile" ] && logfile=$AMS_LOGFILE

or:

	test -z "$logfile" && logfile=$AMS_LOGFILE

then one would look at the test man page to figure out what the command is doing. But the [[ expression ]] command is part of the syntax of some shells and is not valid in other shells. Therefore, one needs to look at the man page for the shell being used to interpret this script. (It may be that the shell's man page will refer the reader to the test man page for the meaning of some of the expressions it evaluates, but most shells that recognize [[ expression ]] also process some expressions that are not accepted by test .)

Hi AKS_Techie,

Note also that the code you have posted sort of looks like a shell function definition, but is not in the correct format and is likely to generate a syntax error.

And, like [[ expression ]] , local is another part of the shell language in some shells and a syntax error in others. As such, you'll need to look at your shell's man page to determine what local does, if anything.

Whenever your start a thread in the UNIX.com forums please tell us what operating system and shell you're using so we can make educated guesses at what your programming environment is. Without that basic information, we may make lots of suggestions that will not work in your environment.

2 Likes

Hi Don, this is Ubuntu..
I was not sure where to look for options of which man page to check the variations...

On Ubuntu, is it still the 'test' man page?

As I said before, it is not the test man page; you need to look at the man page for the shell you are using to interpret that script (and you still haven't told us what shell or operating system you're using).

And, until you answer the "Is this a homework assignment?" question, you won't receive any further help on this topic.

Shell: Bash
OS: RedHat version 7...

Pls advice which man page do I refer or how to I start to look for all the permittable options on this shell..

Since you refuse to answer the homework question, I have to assume that this is, in fact, a request asking us to do your homework for you. Homework and coursework questions can only be posted in the Homework & Coursework Questions forum under special homework rules. Please follow the directions included in those rules and repost your question in that forum with a completely filled out form as required when posting there.

This thread is closed.