现在的位置: 首页 > 综合 > 正文

Shell脚本中一些常用命令

2013年12月03日 ⁄ 综合 ⁄ 共 313字 ⁄ 字号 评论关闭

1、pwd=`cat $jdbc_file | grep password | awk -F'=' '{print $2}'`

-F ':' (来自百度知道)
就是说输入文本是通过冒号 : 来区分字段的,如果你不用-F声明分隔符,那么awk默认是用空格/tab来分隔字段的。 比如你有 a.txt,内容是

hello world: This is world

如果你用 awk '{print $1, $2}' a.txt
那么得到的是
hello world:
两个字段分别是 hello 和world:

而如果你用 awk -F ':' {print $1, $2}' a.txt
那么得到就是
hello world  this is world
两个字段分别是 "hello world" 和 “this is world”了.

 

抱歉!评论已关闭.