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.
如何更好地比较两个文件的某些行(以“@”开头的行)的以下方法?我确信这可以在一条线上完成,而不会造成尴尬的临时文件。我对 Linux 还很陌生,所以请放轻松!提前致谢。
grep "^@" myfile1 > temp1 grep "^@" myfile2 > temp2 diff temp1 temp2
在 Bash 中,您可以使用<(...),它将为您处理临时文件(通常在后台实现为命名管道):
<(...)
diff <(grep "^@" myfile1) <(grep "^@" myfile2)