Bash
如何編譯和管道執行檔的輸出資訊
.... .... checking whether gcc supports -Wl,--as-needed... yes configure: using compiler=gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 configure: using CPPFLAGS= -D_GNU_SOURCE configure: using LDFLAGS= -Wl,--as-needed configure: creating ./config.status config.status: creating GNUmakefile config.status: creating src/Makefile.global config.status: creating src/include/pg_config.h config.status: src/include/pg_config.h is unchanged config.status: creating src/include/pg_config_ext.h config.status: src/include/pg_config_ext.h is unchanged config.status: creating src/interfaces/ecpg/include/ecpg_config.h config.status: src/interfaces/ecpg/include/ecpg_config.h is unchanged config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c config.status: linking src/include/port/linux.h to src/include/pg_config_os.h config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
試圖大致了解一下 postgresql 是如何編譯的。我希望它執行 ./configure 並將輸出資訊通過管道傳輸到文本文件中。
sudo ./configure | /home/jian/fo1.txt
錯誤:
./configure: line 2885: printf: write error: Broken pipe
您搜尋的運算符是
>
。這會將命令的輸出重定向到特定的設備或文件:sudo ./configure >output_file.txt
如果您想在不同的文件中擷取錯誤(STDERR),您應該使用:
sudo ./configure >output_file.txt 2>>output_err.txt
如果要將輸出附加到現有文件,則應使用
>>
sudo ./configure >>output_file.txt
你不需要
sudo
在你的./configure
線路上。您的命令可能應該是:
./configure. |& tee home/jian/fo1.txt
您可能必須清理
root
您之前嘗試創建的所有 -owned 文件,因此:sudo find . -maxdepth 1 -user root -ls # when you're happy with the list of files, replace `-ls` with `-delete`. sudo find . -maxdepth 1 -user root -delete