Guru
Guru

Reputation: 47

Refering file path by variable in shell script

I want to refer file path through variable in script but not aware of syntax.

#!/bin/bash
filepath = /tibcouat1_fs/tibco/deployment/egypt/bnk/broker/logs/;
echo "============BNKBroker=============="
grep 'EXSTAT|' $filepath/bnkbroker.log

Find above script I have created where I am getting below error.

bash-3.2$ ./BNKSrvcList.sh 
./BNKSrvcList.sh: line 2: filepath: command not found
============BNKBroker=====  =========
grep: can't open /bnkbroker.log
bash-3.2$ 

Upvotes: 1

Views: 5461

Answers (2)

Arnab Nandy
Arnab Nandy

Reputation: 6702

Try using this

filepath='/tibcouat1_fs/tibco/deployment/egypt/bnk/broker/logs/';

Upvotes: 3

Robin Hsu
Robin Hsu

Reputation: 4484

You can not have spaces at both sides of the equal sign (=), try this:

filepath=/tibcouat1_fs/tibco/deployment/egypt/bnk/broker/logs/

Upvotes: 4

Related Questions