如何解决在文件 foo 中,如何使用 grep 定位和打印所有包含 printf 的行,但不包含 sprintf 和 fprintf,除了在行尾之外的任何位置?
我对 Unix 还是很陌生,我正在努力克服这个问题练习。我正在使用 grep 命令来完成这项任务,我知道我将不得不使用管道,但我遗漏了一些东西。到目前为止,我能够使用 grep 排除任何带有 sprintf 和 fprintf 的行,但是它不应该打印出以 printf 作为句子结尾的行,而且我不太确定我缺少什么来完成它。我将在下面的终端中发布我的工作作为参考。
这是我正在阅读的文件:
ifsmy12@cloudshell:~/3300/assignments/a7 (cs3300-301722)$ cat foo.txt
You should not pay attention to printf
sprintf would be cool but we dont need it
I think the printf command is fun
fprintf is not needed either
printf acceptable in this case
printf sprintf fprintf printf sprintf printf
What does sprintf printf and fprintf mean
In order to get printf I need to use grep
goodbye
这是我的命令和输出:
ifsmy12@cloudshell:~/3300/assignments/a7 (cs3300-301722)$ grep 'printf'
foo.txt | grep -v 'sprintf' | grep -v 'fprintf'
You should not pay attention to printf
I think the printf command is fun
printf acceptable in this case
In order to get printf I need to use grep
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。