简体   繁体   English

bash管道-从输出中打印某些单元格

[英]bash pipes - print certain cell from output

I'm not sure if this is a very basic question or if I'm making progress, but what I'm trying (and failing) to do is compare two files with diff, then print a certain column from a selected row from the output. 我不确定这是一个非常基本的问题还是正在取得进展,但是我正在尝试(但失败)的是将两个文件与diff进行比较,然后从列表中的选定行中打印特定的列输出。 Basically one cell therefore is the output I want. 因此,基本上一个单元格就是我想要的输出。

diff fileA fileB | ta=$(awk '{print $2}') | awk 'FNR==2'  $ta

obviously doesn't work because $ta isn't a file. 显然不起作用,因为$ ta不是文件。

What's the best (easiest or fastest) way to do this? 最好(最简单或最快)的方法是什么?

不确定要达到的目标,但这应该可以做到

diff fileA fileB | awk 'FNR == 2 {print $2}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM