Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-07-2012, 06:43 PM   #1
LQ Newbie
Registered: Dec 2012
Posts: 9

Rep: Reputation: Disabled
Functions in UNIX

I'm trying to create a function using this
eo (){let re=$1%2; if (($re != 0)); then; echo "Odd"; else; echo "Even"; fi;}
but for some reason I keep getting this error message..
bash: syntax error near unexpected token `{let'
what am I missing?
Old 12-07-2012, 07:23 PM   #2
LQ Veteran
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,678
Blog Entries: 1

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
Try the following:

eo () { let re=$1%2; if (($re != 0)); then echo "Odd"; else echo "Even"; fi;}
Please note the absence of semi-colons after if / then.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
OSE system call functions to Linux Sytem Call functions required roshantraj30 Linux - General 0 06-08-2009 02:06 AM
In UNIX/LINUX, some functions like LoadLibrary and GetProcAddress? chenjifu Programming 3 04-20-2009 02:24 PM
newbie to unix programming in C, needed a few simple prgs on these functions! wrapster Programming 7 06-29-2008 01:23 AM
LXer: Calc functions, part 1: Understanding functions LXer Syndicated Linux News 0 03-31-2007 12:01 PM
pointers to functions/member functions champ Programming 2 03-28-2003 06:22 PM

All times are GMT -5. The time now is 02:11 AM.

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