Failed to create properties file in shell script

I tried the following two ways to source the properties file

#!/bin/sh . import.properties echo $USER_ID echo $INPUT_FILE 

It says:

 ./test.sh[3]: import.properties: not found 

when trying to use source import.properties it gave a message like:

 ./test.sh[3]: source: not found. 

I am very new to scripting and env. Please let me know what I am missing here?

+6
source share
1 answer

To find the dot command . , the file must be readable (optionally executable) and on your PATH (and for safe use it must contain a shell script).

If the file is in your current directory and . (directory, not command) is not on your PATH, you can use:

 . ./import.properties 

Otherwise, you need to specify the absolute file name or relative file name or move the file to a convenient directory on your PATH.

The alternative notation source import.properties fails because you are not in the C shell, and because you are not using Bash. The source command in the C shell is analogous to the dot command in the Bourne shell. Bash allows you to use it as a synonym for the dot command (or the dot command as a synonym for the source). Since source not found, we can safely assume that your shell does not support it as inline.

+12
source

Source: https://habr.com/ru/post/906355/


All Articles