从另一个命令的输出选择文本的一部分 [英] selecting part of text from output of another command
本文介绍了从另一个命令的输出选择文本的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是的grep命令的输出。
The following is the output of "grep" command.
grep -R 'table="transaction"' /home/shantanu/*
/home/shantanu/conf/transaction/Transaction.hbm.xml: <class name="com.common.core.transaction.entity.Transaction" table="transaction">
我想从上面的行抢班名称:
I want to grab the class name from the above line:
com.common.core.transaction.entity.Transaction
这是在双引号中的第一个变量。
It is the first variable in double quotes.
推荐答案
这方面的一些变种:
grep -R 'table="transaction"' /home/shantanu/* \
| sed 's/.*name="\(.*\)" table.*/\1/'
应该让你那里。你会想之前和之后的 \\调节的东西(。* \\)
是取决于你到底有处理数据更严格或宽松。
should get you there. You'll want to adjust the stuff before and after \(.*\)
to be tighter or looser depending on all the data you end having to process.
这篇关于从另一个命令的输出选择文本的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文