![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calling function inside awk | jisha | Shell Programming and Scripting | 2 | 04-14-2008 08:44 AM |
| Calling a function | ashika | UNIX for Dummies Questions & Answers | 5 | 09-12-2006 08:58 PM |
| Calling other file function | maldini | Shell Programming and Scripting | 3 | 08-19-2005 03:23 AM |
| calling c++ function from script | Lebamb | High Level Programming | 3 | 06-24-2003 10:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Calling on function from file??
This may sounds dumb, but can I call on a function from a file? For example, I have a function file full of functions like below (no shell designation): Code:
func { echo "blah blah blah 1" }
func2 { echo "blah blah blah 2" }
func3 { echo "blah blah blah 3" }
Am I able to call on any one of these specific functions from another script? If so, how? TIA
|
|
||||
|
(Talking about bash) Yes, you can use those functions from another file if they have the correct syntax which is not the case. For bash functions you could have a file say file_number_one.sh: Code:
function func { echo "bla bla bla1"; }
and then from another script you could have: Code:
. ./file_number_one.sh func |
|
||||
|
As an aside, function is a Bashism. The POSIX way to declare a function is Code:
func () { body of function; }
I care because it bit me when I switched shells (or rather, Ubuntu switched shells on me). |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|