![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| if statement | ramky79 | Shell Programming and Scripting | 6 | 05-29-2008 03:17 AM |
| IF Statement | koti_rama | Shell Programming and Scripting | 3 | 04-29-2008 04:48 AM |
| If statement - How to write a null statement | april | Shell Programming and Scripting | 3 | 04-16-2008 01:14 PM |
| using && in if statement .. | jisha | Shell Programming and Scripting | 7 | 02-01-2008 07:52 AM |
| If statement | mariner | UNIX for Advanced & Expert Users | 4 | 12-16-2004 07:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am working in korn shell ad I have the following problem:
EXPORTALLFIRST=Y I have an if statement in my program if [ "${EXPORTALLFIRST}" -eq Y ] then and I am getting the following error export.sh[28]: Y: 0403-009 The specified number is not valid for this command. Do you see any obvious errors? |
|
||||
|
Having trouble with simple If Statement
I'm trying to run a simple If statement, but am getting errors....please advise
#!/bin/bash echo What is your name? read name if $name = Peter then echo Hey! That is my name, too! else echo That is not a bad name either. fi It doesn't seem to like line 4. How do I tighten that up so that it will work correctly? Thanks, and I realize this really is UNIX child's play. I just don't have anyone else to ask. |
|
||||
|
You need to use 'test'. The shell itself calls a separate program to do the string comparison. You should probably use quotes too, though you may be able to get by without them.
Code:
#!/bin/bash echo What is your name? read name if [ $name = "Peter" ] then echo Hey! That is my name, too! else echo That is not a bad name either. fi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|