请问如何从一个文件中获取两个字符串(或整行)并将它们写在输出文件的同一行中?
grep -e "string1 string2" inputfile > output.txt doesn't work
它适用于一个字符串:
grep -e "string1" inputfile > output.txt
THX!
答案 0 :(得分:1)
更改你的grep命令,如下所示,
grep -o 'string1\|string2' file | paste - - > out.txt
这会将string1 string2
写在out.txt