Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从文件中提取地址。
grep keyword /path/to/file
是我如何找到我想要的代码行。输出类似于
var=http://address
考虑到我正在寻找的关键字在和部分中,有没有办法我可以直接在=ie之后获得部分http://addressvarhttp://address
=
http://address
var
grep keyword /path/to/file | cut -d= -f2-
只需管道到cut:
cut
grep keyword /path/to/file | cut -d '=' -f 2
您可以避免不必要的管道:
awk -F= '/keyword/{print $2}' /path/to/file