Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


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 !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-13-2012
Registered User
 
Join Date: Jul 2011
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
multiple if conditions and EOF in a shell script

I want to create an IF condition with multiple condition, in the statement below I want to add OR EOF, can any one please advise how to do.

Code:
if [ ${array[5]} !=  $sample ] && [ $c -eq 1 ]; then

echo .....

fi

Moderator's Comments:
code tags please

Last edited by jim mcnamara; 04-13-2012 at 05:15 PM.. Reason: code tags
Sponsored Links
    #2  
Old 04-13-2012
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 9,650
Thanks: 164
Thanked 642 Times in 619 Posts

Code:
#!/bin/bash
if [[ "${array[5]}" !=  "$sample"  &&  $c -eq 1 ]]; then
  # do stuff here
fi

use [[ and ]]

always put quotes around string variables or empty variables can generate errors that stop the script.

EOF: this is sort of the standard way to read file in straight shell and write the output to a file


Code:
while [[  read variable_name   &&   $farkle="something"  ]]
do
  # stuff goes here
  echo "something you want to see in the output file"

done < /path/to/inputfile   >  /path/to/outputfile

you can also exit a loop early with the break keyword

Last edited by jim mcnamara; 04-13-2012 at 05:45 PM.. Reason: forgot EOF
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
specifying multiple conditions in AWK skyineyes Shell Programming and Scripting 2 05-12-2010 10:31 AM
Help regarding multiple conditions ssenthilkumar Shell Programming and Scripting 4 01-08-2010 02:10 AM
How to Use Multiple if Conditions in Shell script dinesh1985 Shell Programming and Scripting 5 06-25-2009 11:10 AM
multiple if conditions bashshadow1979 Shell Programming and Scripting 4 04-21-2009 03:08 PM
multiple conditions in if/then grandtheftander UNIX for Dummies Questions & Answers 4 07-21-2006 01:58 PM



All times are GMT -4. The time now is 04:55 PM.