從配置檔案中提取IP

fjzcau發表於2015-01-24
--提取配置檔案111.txt中的ip:

[etl@cppimii-etl01 fjz_script]$ cat 111.txt
db = oracle
ip = 10.3.7.111

[etl@cppimii-etl01 fjz_script]$ sed -n '/ip/'p 111.txt  | awk -F= '{print $2}'
10.3.7.111

[etl@cppimii-etl01 fjz_script]$ cat 111.txt
db = oracle
ip = 10.3.7.111
date=2012/05/12=end

[etl@cppimii-etl01 fjz_script]$ sed -n '/date/'p 111.txt  | awk -F= '{print $3}'
end


[etl@cppimii-etl01 fjz_script]$  cat 111.txt
db = oracle
ip = 10.3.7.111
date=2012/05/12=

[etl@cppimii-etl01 fjz_script]$  sed -n '/\(=\)[0-9]\{4\}\/[0-9]\{2\}\/[0-9]\{2\}\1/'p 111.txt
date=2012/05/12=

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22661144/viewspace-1412901/,如需轉載,請註明出處,否則將追究法律責任。

相關文章