LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-23-2004, 12:04 PM   #1
test
Newbie
 
Registered: Apr 2004
Posts: 14

Rep: Reputation: 0
Good scripting practices?


Hi, I'm new to linux and bash scripting.

I'm trying to write a quite large and complex script(s), and seperating some commonly used functions etc. in own files seems like a good idea. What is good programming practice here?
 
Old 04-23-2004, 01:56 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Welcome to LQ.

You can define a function with:
Code:
#!/bin/bash
# This is "myfunction.sh"
myfunction() {
  echo My Function
}
To load it in another script with:
Code:
#!/bin/bash
# This is "script.sh"

# Load the function
. /path/to/myfunction.sh

# Run the function
myfunction
 
Old 04-26-2004, 11:55 PM   #3
TheOther1
Member
 
Registered: Feb 2003
Location: Atlanta, GA
Distribution: RHAS 2.1, RHEL3, RHEL4, SLES 8.3, SLES 9, SLES9_64, SuSE 9.3 Pro, Ubuntu, Gentoo
Posts: 335

Rep: Reputation: 32
You may find the Advanced Bash Scripiting Guide useful...
 
  


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
Good practices as programmer interview candidate? lowpro2k3 Programming 3 10-21-2005 03:15 PM
Partitioning: Best Practices newtype Linux - General 2 06-05-2004 08:44 AM
Best practices for upgrading hyper guy General 5 05-28-2004 01:39 AM
Seeking for a good scripting language... Frank Programming 11 01-02-2004 11:35 PM
Best Practices mooreted Linux - Software 4 06-12-2003 01:31 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration