![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Conditonal clause in expect. | akbar | Shell Programming and Scripting | 1 | 05-13-2008 04:28 PM |
| if clause | palmer18 | UNIX for Dummies Questions & Answers | 3 | 08-08-2007 06:22 AM |
| if clause in AWK END block not working. | satnamx | Shell Programming and Scripting | 1 | 04-21-2006 03:29 AM |
| Math Square Root | davex4285 | Shell Programming and Scripting | 3 | 01-29-2006 06:03 PM |
| square brackets | gilead29 | UNIX for Dummies Questions & Answers | 2 | 02-03-2004 07:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
why put double square brackets in an if clause?
what is the rationale behind putting double square brackets in an if clause?
for e.g. if [[ ${APPNAME} = '' ]] || [[ ${SRCSYSNAME} = '' ]] || [[ ${FILENAME} = '' ]]; then echo some fields are null fi |
| Forum Sponsor | ||
|
|
|
|||
|
The following is a segment from that post.
"There is a command called [ and like many commands it takes parameters. It checks its last parameter and gets mad unless it is ]. If the last parameter is a ], it looks at everything else and tries to determine what you are trying to test. If you do: lines="" if [ $lines -eq 0 ] you will have a problem. All that the [ command will see is the -eq and the 0 so it will complain. Because of these concerns, Dave Korn invented another syntax. Now you can do: if [[ $lines = 0 ]] and it won't get mixed up as easily." 'All that the [ command will see is the -eq and the 0'...why so? why wont it see the ']' ? isnt ']' the last argument for command '[' ? plz explain. and by 'it looks at everything else' , u mean that it looks inside the square brackets? if so, then i dont see, why the first format shudnt work. (it isnt working, obviously, but i cant get the reason) |