对于文件中的一个单词/模式,我要grep,如果文件中不存在这样的模式,那么我要打印/echo "-“。我们可以在命令行中使用一行命令来执行此操作吗?grep word <file> | <command to return "-" if "word" not present in file> python
有了这只awk单线awk '{lines[NR]=$0}{for(i=0;i<3;i++) print $lines[i]} awk.writethis line 1 no un1xTHIS is notbutbutbut ffffsecond linesecond line
然而,在这里,$的使用似乎是不同的</em