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


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers [[ -e $filename ]] - which man page to refer to these options
# 1  
Old 03-02-2019
[[ -e $filename ]] - which man page to refer to these options

What does this do:
Code:
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

Moderator's Comments:
Mod Comment Please wrap your commands/samples in code tags, see how I wrapped them.

Last edited by RavinderSingh13; 03-03-2019 at 12:42 AM..
# 2  
Old 03-03-2019
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
# 3  
Old 03-03-2019
Hi Ravinder,
Sorry, but I have to disagree with you here. If the command was:
Code:
	[ -z $logfile ] && logfile=$AMS_LOGFILE

or:
Code:
	test -z $logfile && logfile=$AMS_LOGFILE

or more correctly if written using test:
Code:
	[ -z "$logfile" ] && logfile=$AMS_LOGFILE

or:
Code:
	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,
Moderator's Comments:
Mod Comment Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

If this is not a homework assignment, please explain the nature of the problem you are working on.

If this is a homework assignment, please review the guidelines for posting homework and repost in the correct forum.

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.

Last edited by Don Cragun; 03-03-2019 at 01:32 AM.. Reason: Fix mismatched parenthesis and misplaced closing italics tag.
These 2 Users Gave Thanks to Don Cragun For This Post:
# 4  
Old 03-03-2019
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?
# 5  
Old 03-03-2019
Quote:
Originally Posted by AKS_Techie
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.
# 6  
Old 03-03-2019
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..
# 7  
Old 03-03-2019
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to write a UNIX man page

I realise that with GNU 'info' a lot of developers become, dare I say it, quite lazy when it comes to providing a well written man page - and some argue they're not needed at all. But I find, in the products that I develop, that man pages are used more often for quick reference, and therefore the... (1 Reply)
Discussion started by: cambridge
1 Replies

2. Solaris

man page question

What does the last change means in man page .. does that this man page has not been updated since 2003 or something else ? newfs-options The options are documented in the newfs man page. SunOS 5.10 Last change: 9 Dec 2003 1 System... (2 Replies)
Discussion started by: fugitive
2 Replies

3. Solaris

Unable to get help from man page

Help, it seem that i am unable to get man help form solaris 10. I am running SunOS unknown 5.10 Generic_120012-14 i86pc i386 i86pc when ever i try to man a command what i get is "No manual entry" like the one below. # man grep No manual entry for grep. # man ls No manual entry for ls.... (8 Replies)
Discussion started by: ezsurf
8 Replies

4. UNIX for Advanced & Expert Users

man page issue

Man page is not working my system. It is giving the following the following error > man ls gdbm fatal: read error with debug option > man -d ls ... .... ... ... using less as pager checking for locale en_US add_nls_manpath(): processing /usr/local/man:/usr/share/man:/usr/X11R6/man... (4 Replies)
Discussion started by: praveenkumar_l
4 Replies

5. Red Hat

scp-1.2.27 man page

Hi Guys, I'm looking for the man page for scp version 1.2.27 I have an old redhat server that has a few large scripts that use this version and I want to know what the -A flag does and the man page is not on there. (4 Replies)
Discussion started by: Tornado
4 Replies

6. Solaris

help interpreting usermod man page

Hi, I put an expiration on a few id's that I want to remove now. From the man page -e expire Specify the future date on which a login can no longer be used; after this date, no user will be able to access this login. This option is useful ... (0 Replies)
Discussion started by: amheck
0 Replies

7. UNIX for Dummies Questions & Answers

adding a man page

I was wonderiong if ther is a way for a user to add a man page specific to thier account. similar to copying the .1 or .1.gz to /usr/share/man/man1 "cp *.1.gz /usr/share/man/man1". Except for using another folder as I don't have access to /usr/share/man/man1. I would think that this might involve... (1 Reply)
Discussion started by: jacob358
1 Replies

8. UNIX for Dummies Questions & Answers

how do you create a man page?

i've never done this before. i created a script that I placed in /usr/bin, but want to create a man page for it. i'm clueless thanks (3 Replies)
Discussion started by: theDirtiest
3 Replies
Login or Register to Ask a Question