Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include File 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

From a Bourne shell script how can I include a file of common functions?

My goal is to create a library of common commands and functions. I am thinking of leaving them uncompiled so as they will work with all UNIX flavors that support the Bourne shell. If there is interest maybe it could be done as an open source project.



Thanks,

Michael42
 
Code:
#!/bin/bash
#
. /home/michael42/lib/bourne_lib.sh
would 'include' bourne_lib.sh.

It would actually read it, so things would be executed, and it might consume some time.

But I don't believe the big-bourne-lib will find much interest. Why isn't there already such a big lib?

Encapsulation which is used in OO-Languages isn't supported by the bash.
The namespace of everything is common, which leads to problems in big scripts.

But don't let yourself stop.
Try it out.
Improve it.
Proofe, that I'm wrong.

P.S.: Instead of the dot, you may use the keyword 'source'.
man bash
search the man with '/'+'source'


seeking a job as java-programmer in Berlin:
 
stefanwagner,

Many thanks. I am finding my self in a position where I need to write MANY scripts and commands like:

Left(MYVAR,5) easier than ...

grepAS)(*S&DF(*sedD_)S(*awkasdhhnawk asjkdf;astwak$MYVAR_S(D*F()*SDF}{}D()DF

:)

Thanks,

Michael42
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top