【发布时间】:2017-06-30 09:02:54
【问题描述】:
我对 grep 命令有一个问题。在我调用的脚本中我使用:
"ServicePassword":fooooooooooo
"ServiceUserName":barrrrrrrrr
grep -E '"ServiceUserName"|"ServicePassword"' >> user.txt
但在 user.txt 文件中,我将首先获得“ServicePassword”:fooooooooooo 然后是“ServiceUserName”:barrrrrrrrr 我如何使用 grep 命令将其反转以在 user.txt 文件中获取第一个 ServiceUserName 然后是 ServicePassword 输出?我只需要这个序列。我尝试改变:
grep -E '""ServicePassword""|"ServiceUserName"' >> user.txt
什么都没有......也许存在更好的解决方案?
【问题讨论】: