linux - 在 shell 脚本中通过变量引用文件路径

标签 linux shell unix

我想通过脚本中的变量引用文件路径,但不知道语法。

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

在我创建的上面的脚本中找到我遇到错误的地方。

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

最佳答案

等号(=)两边不能有空格,试试这个:

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

关于linux - 在 shell 脚本中通过变量引用文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26966462/

相关文章:

php - UTF-8贯穿始终

java - 我可以从 java 程序更改 linux 中的用户密码吗?

python - Python 3.5.1 Shell 中的简单 http 服务器

unix - 结合两个 ffmpeg 命令

sockets - SO_REUSEADDR 和 AF_UNIX

c - strcat 覆盖了我的字符串

linux - 从 Matlab 启动 Linux 终端

linux - .sh 文件的 CI Jenkins 权限被拒绝

linux - 将负载分配给多个 cron 作业

Linux I/O 重定向