LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-07-2004, 04:06 PM   #1
MIC_Rulz
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
bash script includes?


I am fairly new to the bash scripting thing. I've written up a nice script to perform some automated work functions. But as I add to the script it has gotten longer and more difficult to manage.

Other programming types allow the use of include files. Does bash scripting offer such a thing? I tried searching for help on this and have not found anything concrete with what I need. The only include I found was in the manual page and it seems to just immediately execute the file.

I have a number of functions or procedures in the script file and would like to let some of those reside in other files. That way I could keep the menu functions in one file, the file manipulation functions in another, etc.

Any help would be appreciated.

Thanks in advance.
 
Old 09-07-2004, 04:15 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Welcome to LQ.

Just source the script to bi included - ie:
Code:
#!/bin/bash

# Load the config
. /path/to/config.sh

# Echo some configuration variable
echo $myconfigvar
 
Old 09-07-2004, 06:46 PM   #3
MIC_Rulz
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Original Poster
Rep: Reputation: 0
That did the trick. Thank you very much. This makes debugging my scripts a bit easier than before. It also seems to be easier to add functionality to as well.
Maybe someday I will get into writing real programs in a real language.
 
  


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
more help with bash script please poiuytrewq Linux - Newbie 6 10-26-2004 10:57 PM
Bash programming .. multiple includes ?? michael_util Programming 2 08-09-2004 12:47 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 06:34 AM


All times are GMT -5. The time now is 08:48 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration