leon1509 发表于 2013-2-4 12:57:23

Linux SHELL读取配置文件中的变量

1. 配置文件内容(a.cfg):
   #!/bin/bashFTP_IP=192.168.1.201FTP_USER=test_userFTP_PASS=123456SRC_DIR=/DIST_DIR=~/data# 文件日期(系统日期减一天)CD=`date +"%Y%m%d" -d'-1 day'`

2. shell脚本
#!/bin/bashsource a.cfgftp -n<<!open $FTP_IPuser $FTP_USER $FTP_PASSbinarycd /home/datalcd $DIST_DIRpromptmget *.datclosebye!

注意:文件格式必须是unix文件格式


参考地址:http://www.myexception.cn/linux-unix/292000.html
页: [1]
查看完整版本: Linux SHELL读取配置文件中的变量