LinuxQuestions.org
Review your favorite Linux distribution.
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 12-31-2007, 11:15 PM   #1
som_kurian
Member
 
Registered: Oct 2007
Posts: 33

Rep: Reputation: 15
Functions in bash script


Is it possible to define functions and called in bash script as in C++
 
Old 01-01-2008, 12:32 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
If you're willing to research a little, Bash functions --> http://tldp.org/LDP/abs/html/abs-guide.html#FUNCTIONS
 
Old 01-01-2008, 08:11 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I strongly recommend downloading the pdf version of ABS and using it for searches. (Don't print it unless you are into killing trees.)
 
Old 01-01-2008, 09:12 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Functions are easy to use in bash. Just be sure that they come first in your script before they are called:

Code:
#!/bin/bash

hello_world() {
echo "Hello world!"
}

hello_world
exit 0
 
  


Reply


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
LXer: Using Functions in a BASH Prompt LXer Syndicated Linux News 0 06-11-2007 02:31 AM
running functions on the same time (bash programming) sharapchi Programming 1 11-12-2006 11:55 AM
Order of functions in a bash script essdeeay Programming 1 05-02-2006 10:52 PM
[bash-scripting]functions + arguments hylke Programming 14 10-05-2004 01:48 AM
dvorak layout = can't use bash functions with xterm elconde Linux - General 2 03-14-2004 05:35 PM

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

All times are GMT -5. The time now is 09:11 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