LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-12-2003, 09:07 AM   #1
xscousr
Member
 
Registered: Jul 2003
Location: Toronto
Distribution: Redhat
Posts: 89

Rep: Reputation: 15
bash scripting question - elif ??


Just trying to expand my bash scripting knowledge and i keep getting a syntax error...
Basically what i'm trying to do is based on ownership of a file i need to perform some commands. In order to do this i've stripped the script down to the base...

If file is owned by dave then do this but if it is owned by bob then do this then end.

#!/bin/bash
#
fname="testfile"
var1=`ls -l $fname | awk ' { print $ 3 }'`

if [ $var1 = dave ]; then

mail -s "Owned by Dave" test@mail.com
elif
if [ $var1 = bob ] ; then
mail -s "File is owned by bob" test@mail.com
fi
 
Old 08-12-2003, 09:49 AM   #2
andrew001
Member
 
Registered: Nov 2002
Distribution: Slackware 9.0
Posts: 321

Rep: Reputation: 30
elif [$var1=bob]; then
mail -s "File is owned by bob" test@mail.com
fi

You don't need to put an 'if' after an 'elif'. See The Advanced Bash Scripting Howto at http://www.itcentrs.lv/linux/docs/HO...ash-Scr-HOWTO/

~Andrew
 
Old 08-12-2003, 09:56 AM   #3
xscousr
Member
 
Registered: Jul 2003
Location: Toronto
Distribution: Redhat
Posts: 89

Original Poster
Rep: Reputation: 15
excellent - thanks Andrew!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Scripting Question fiod Linux - Newbie 4 11-19-2005 05:09 AM
Bash scripting question Hammett Linux - General 4 11-29-2004 06:29 AM
Bash scripting question. welby Linux - Software 1 01-14-2004 10:05 AM
bash scripting question brian0918 Linux - Newbie 7 06-26-2003 03:48 PM
Scripting Question (BASH) merana Linux - General 4 01-12-2003 01:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration