在gnu制作中使用grep

发布于 2025-01-25 11:16:44 字数 588 浏览 2 评论 0原文


首先:我是Linux的新手,我已经很抱歉问一个可能的愚蠢问题。
我有一个将乳胶文本编译成pdf的makefile。这会创建一个日志文件,我必须在该日志文件中搜索一个字符串,并在字符串中在日志文件中再次编译。 因此,一切都可以正常运行,直到我的命令为止。 我正在尝试使用GREP命令检查子弦,但不要让它起作用。 在我的解决方案中,即使子字符串不在我的日志文件中,也执行IF语句。

GREP_FINDINGS := $(shell grep 'undefhrined' linux-20.log)

all: clean linux-20.pdf
ifeq ($(GREP_FINDINGS),)
    pdflatex linux-20
endif

linux-20.pdf:
    pdflatex linux-20
    bibtex linux-20
    pdflatex linux-20
    
.PHONY: clean
    
clean:
    echo Cleaning .aux .bbl .blg .log files
    -rm -f *.aux *.bbl *.blg *.log *.pdf
    echo Cleaning complete.

First: I'm pretty new to linux and I'm already sorry for asking a probably dumb question.
I have a makefile that compiles a latex text into a pdf. That creates a logfile and I have to search for a string in that log file and compile again if the string is in the log-file.
So everything works fine until to the point of my if-statement.
I'm trying to check for the sub-string with the grep command but dont get it to work.
In my solution the if statement is executed even if the substring is not in my logfile.

GREP_FINDINGS := $(shell grep 'undefhrined' linux-20.log)

all: clean linux-20.pdf
ifeq ($(GREP_FINDINGS),)
    pdflatex linux-20
endif

linux-20.pdf:
    pdflatex linux-20
    bibtex linux-20
    pdflatex linux-20
    
.PHONY: clean
    
clean:
    echo Cleaning .aux .bbl .blg .log files
    -rm -f *.aux *.bbl *.blg *.log *.pdf
    echo Cleaning complete.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮酒 2025-02-01 11:16:44

这个问题的某些部分使我感到不安(例如第一个通过后的某些东西是 不确定的,但第二个是在第二次 - 或第三次之后?),但是如果您要的是什么?想要,然后我将有条件的条件放入规则中:

linux-20.pdf:
    pdflatex linux-20
    bibtex linux-20
    pdflatex linux-20
    !(grep undefined linux-20.log) || pdflatex linux-20

Some parts of this question make me uneasy (such as something being undefined after the first pass but all square after the second -- or third?), but if what you're asking for is actually what you want, then I'd put the conditional inside the rule:

linux-20.pdf:
    pdflatex linux-20
    bibtex linux-20
    pdflatex linux-20
    !(grep undefined linux-20.log) || pdflatex linux-20
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文