shell指令碼讀取配置檔案【有圖有真相】
配置檔案config.properties
#以下是配置檔案內容,配置檔案檔名為config.properties
username=jack
password=33281
shell指令碼(指令碼名為 readConfig.sh)
#!/bin/bash
source ./config.properties
echo ${username}
注意:我這裡把config.properties和readConfig.sh放置在同一資料夾下。
執行結果貼圖
說明:如果轉載請註明出處!!
相關推薦
shell指令碼讀取配置檔案【有圖有真相】
配置檔案config.properties #以下是配置檔案內容,配置檔案檔名為config.properties username=jack password=33281 shell指令碼(指令碼名為 readConfig.sh) #!/bin/bash sour
Linux Shell 指令碼讀取配置檔案
一、應用場景 為了靈活應用shell指令碼,適當的加入配置檔案,對於後期的維護和優化會有很大幫助。例如指令碼中使用的檔案/檔案路徑,都可以通過讀取配置檔案完成。 配置檔案 filename=boomlee 指令碼檔案 #!/bin/bash workdir=$(cd $(di
python指令碼 讀取配置檔案cfg 不讀#號和空行
對配置upxxx.cfg 檔案,內容如下的讀取 #使用教程:zaper不能為零 #同時#後面代表要更新的包 zkper=0# ucs=1#mips_ucs-1.8.1-bin.tar.gz 讀取以上檔案內容,如下指令碼: #!/usr/bin/python # -*- coding: utf-8 -
bat指令碼讀取配置檔案
bat 讀取配置檔案 @echo off :: echo please input(is not null):user passsword expath date :: 讀取配置檔案 where bcp ::正式有bcp放開下面這句話 ::if "%errorlevel%
shell指令碼修改配置檔案中引數
shell指令碼修改配置檔案中引數指令碼:change_ejabberd.sh內容如下:注意:cut的用法:cut命令主要是接受三個定位方法:第一,位元組(bytes),用選項-b第二,字元(characters),用選項-c第三,域(fields),用選項-f
shell指令碼獲取配置檔案中的內容
1、獲取配置檔案中的內容。 步驟是1,2,3. 2.刪除一個檔案中的內容,然後追加自己需要的內容,這裡的先將檔案中的內容刪除,然後新增1234進去。 3.在某行的前一行或後一行新增內容 具休操作如下: #匹配行前加 sed -i '/allow 361
linux shell 指令碼讀取 ini 配置檔案
linux shell 指令碼讀取 ini 配置檔打碼如下: #!/bin/bash configFile="./config.ini" function ReadINIfile() { Key=$1 Section=$2 Configfile=$
shell指令碼讀取ini配置檔案的值
[comon] ids=com1,com2,com3 files=profilefile [com1] key="name" file="test" [com2] key="name1" file="test" [com3] key="name2" file
Shell指令碼讀取ini配置檔案例項教程
分享下Shell指令碼讀取ini配置檔案的實現程式碼,分為簡單版與複雜版二個版本。 一、簡單版 參考stackoverflow的例子,改了一個出來: while IFS='= ' read var val do if [[ $var == \[*] ]] t
linux shell 指令碼讀取 ini 配置檔案(命令部分詳解)
wanxiaoderen: 這句 判斷理解難度略高,查資料半天后,我來解釋下 (awk的使用(不瞭解的可以掃盲)http://blog.chinaunix.net/uid-23302288-id-3785105.html) ReadINI=`awk -F '=' '
linux shell 讀取配置檔案
隨著linux接觸的越來越多,我們難免需要從一些配置檔案中進行讀取配置引數,linux中shell屬於指令碼型語言,讀取時沒有其它語言方便,特將用過的一種方式分享給大家 實戰程式碼: $ more a.txt name=hello world age=22 ip=192.168.
Linux通過cat EOF新建檔案並新增或追加內容方法並在shell指令碼中配置環境變數時使用
cat << EOF >實現新建檔案並新增內容 [email protected]:/opt# cat << EOF >abcd.txt > 1 > 2 > 3 > eof > EOF [email
【Java】讀取配置檔案
package utils.properties; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Concu
【java】 一個讀取配置檔案的類
/** * <p>Title:InitConfig.java</p> * <p>Description:</p> * @author songrongkai * @date 2018年7月29日 * @version 1.0 */ p
解決shell讀取配置檔案key帶點號(.)的問題
傳統source讀取方式 #application.properties db.uat.user=user db.uat.password=password db.uat.url=https://www.baidu.com #!/bin/sh source "application.pr
【shell】shell指令碼在大檔案日誌中按照時間段快速搜尋日誌
問題描述: 在大流量線上服務中,日誌系統會產生數量龐大的日誌,動輒就是幾十G。在如此之大的檔案中快速搜尋日誌是運維人員經常遇見的問題。我們經常遇見的問題是查詢一段時間內的某些條日誌。比如,今天有一
【Linux】Shell - 指令碼練習 - 擷取檔案內容
寫一個指令碼 依次向/etc/passwd中的每個使用者問好,並且說出對方的ID是什麼 例如:Hello root, your UID is0. 方法1:使用awk指定分隔符 cat /etc/passwd | awk -F ":" '{print "H
解決shell檔案讀取配置檔案key帶點號(.)的問題
傳統source讀取方式 #application.properties db.uat.user=user db.uat.password=password db.uat.url=https://www.baidu.com #!/bin/sh source "app
【SpringBoot】——SpringBoot 讀取配置檔案方式
// 方式一: 將配置檔案封裝為一個bean @Autowired private ConfigProps configProps; // 方式二: 通過 Spring 提供的類獲取配置檔案 @Autowired private Environment environmen
Linux--shell 讀取配置檔案的方法
配置檔案config內容如下ID=123 IP=192.168.3.154 Name=test 方法一,利用sed解析文字,提取配置資訊 id=`sed '/^ID=/!d;s/.*=//' urfile` ip=`sed '/^IP=/!d;s/.*=/