Jeegar Patel
Jeegar Patel

Reputation: 27240

Reading commands from another file in a shell script?

see i want to use source command in my shell script. Now when i type source on terminal it shows like

-bash: source: filename argument required
source: usage: source filename [arguments]

now when i use this in my shell script like this

#!/bin/sh
source

and save as test.sh

and run then get like this

./test.sh: 2: source: not found

How to solve this problem?

Upvotes: 0

Views: 2149

Answers (1)

knittl
knittl

Reputation: 265938

You run your script with sh, not with bash. source does not exist in plain sh, but you can use . instead, it means the same thing.

#!/bin/sh
. /path/to/other/script
function_defined_in_other_script

Upvotes: 5

Related Questions