The content of Path.property
should not include spaces before/after the = sign.
filepath1=/var/log/Test
filepath2=/home/Backups
The following script will print the value of the variables:
source Path.property
echo $filepath1
echo $filepath2
You can replace the echo
with mv
,rm
commands, etc.
It works like that:
Variable file
$ cat Path.property
filepath1=/var/log/Test
filepath2=/home/Backups
Script file
$ cat printvar.sh
#!/bin/bash
source Path.property
echo $filepath1
echo $filepath2
execution of the script
$ bash printvar.sh
/var/log/Test
/home/Backups
echo $filepath1
I am getting blank output it means it is not reading values inside FilePathInfo.properties.
– Jyothsna Chilukuri Mar 23 '17 at 09:26=
from thesource
command – Yaron Mar 23 '17 at 09:27Path.property
which holds the two lines in my answer, and copy/paste the next 3 lines intoshell
– Yaron Mar 23 '17 at 09:28printvar.sh
andPath.property
, and a command to runprintvar.sh
, and the result output. Please try it. – Yaron Mar 23 '17 at 09:40bash
, and afterwards runsource Path.property echo $filepath1 echo $filepath2
– Yaron Mar 23 '17 at 11:07