反转gcc输出的顺序 [英] Inverting the order of the gcc output

查看:83
本文介绍了反转gcc输出的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想逆转由gcc在我的程序中发现的错误的顺序.为什么?读取最后一行的第一个错误,并避免滚动到第一行.

I'd like to reverse the order of the errors founded by gcc in my programs. Why? to read the first error at last line and avoid to scroll until the first line.

我在gcc,cat,tail和head手册中搜索了--reverse之类的命令,但没有结果.因此,我想要一个以相反顺序打印标准输入的程序.有人知道吗?

I searched on gcc, cat, tail and head manuals for an command like --reverse without results. So, I'd like to a program who print the standard input in inverse order. Anyone knows something like that?

推荐答案

您可以尝试以下脚本:

unbuffer gcc main.c 2>&1 | tac

说明:

  • unbuffer:禁用管道缓冲,并允许gcc在执行过程中保留其配色方案.
  • gcc main.c 2>&1:
    • 您的gcc命令可以根据需要使用,并且可以包含您通常使用的所有标签(它不仅限于1个文件.只需将重定向作为最后一个参数)
    • 2>&1:I/O重定向. stderr重定向到stdout
    • unbuffer : disables buffering for the pipe, and allows gcc to retain its color scheme through the execution.
    • gcc main.c 2>&1 :
      • Your gcc command can be as long as you need and contain all the falgs you usually use (it is not limited to just 1 file. Just keep the redirection as the last parameter)
      • 2>&1 : I/O redirection. stderr is redirected to stdout

      如果您的计算机上尚未安装它,则unbuffer在基于Debian的发行版的软件包expect-dev中,而taccoreutils的一部分.

      If you don't have it installed on your machine, unbuffer is in the package expect-dev on Debian based distros, and tac is part of coreutils.

      这篇关于反转gcc输出的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆