gnu

Why does “find . -name *.txt | xargs du -hc” give multiple totals?

半腔热情 提交于 2019-12-18 13:21:34
问题 I have a large set of directories for which I'm trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works: find . -name *.txt | xargs du -hc But instead of giving me one total at the end, I get several. My guess is that the pipe will only pass on so many lines of find's output at a time, and du just operates on each batch as it comes. Is there a way around this? Thanks! Alex 回答1: How about using the --files0-from option to du? You'd have to

Bloated echo command

做~自己de王妃 提交于 2019-12-18 11:57:25
问题 Look at the following implementations of the "echo" command: http://bxr.su/o/bin/echo/echo.c (OpenBSD) http://bxr.su/d/bin/echo/echo.c (DragonFly) http://bxr.su/n/bin/echo/echo.c (NetBSD) http://bxr.su/f/bin/echo/echo.c (FreeBSD) http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/echo.c (GNU) As you go down the list, I'm sure you'll notice the increasing bloat in each implementation. What is the point of a 272 line echo program? 回答1: In their article 'Program Design in the UNIX

getting c++11 - compliant compiler

懵懂的女人 提交于 2019-12-18 11:53:58
问题 This all seems like a colossal mess. All I want is a compiler that implements C++11, so I can use <chrono> . But I'm so confused from the very beginning. Currently, I build programs by invoking G++, but when I check the version via $ g++ -v , I get: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) What's going on? Am I using G++? GCC? LLVM? I don't even know. Are they the same thing? So now I'm trying to build and download GCC 4.7 via gnu.org, but I have no idea what

gcc-arm-linux-gnueabi command not found

随声附和 提交于 2019-12-18 10:23:14
问题 I am trying to install the gnu arm toolchain for ubuntu. I first downloaded the tar from CodeSourcery. However when I go into the bin folder, I cannot run any of the binaries. I have tried with ./ and without and putting it in the PATH and it keeps telling me "Command not Found" yet the file is there in the folder right in front of me. Then I tried sudo apt-get install gcc-arm-linux-gnueabi except after it says it has installed successfully, I cannot find it with whereis gcc-arm-linux-gnueabi

shell编程(1)

℡╲_俬逩灬. 提交于 2019-12-18 09:54:00
一、shell简介   1.脚本:脚本就是一些命令的堆积。   常见的脚本: JavaScript(J S ,前端) ,VBScript, ASP, JSP,PHP(后端) ,SQL(数据库操作语言),Perl, Shell ,python,Ruby,JavaFX, Lua等。   2.shell的优势:    ①Shell属于内置的脚本   ②程序开发的效率非常高,依赖于功能强大的命令可以迅速地完成开发任务(批处理)   ③语法简单,代码写起来比较轻松,简单易学   3.shell简介   Shell 是一个 C 语言编写的脚本语言,它是用户与 Linux 的桥梁,用户输入命令交给 Shell 处理, Shell 将相应的操作传递给内核(Kernel),内核把处理的结果输出给用户。 下面是流程示意图: Shell 既然是工作在 Linux 内核之上,那我们也有必要了解下 Linux 相关知识。 Linux 是一套免费试用和自由传播的类 Unix 操作系统,是一个基于 POSIX 和 UNIX 的多用户、多任 务、支持多线程和多 CPU 的操作系统。 1983 年 9 月 27 日,Richard Stallman(理查德-马修-斯托曼)发起 GNU 计划,它的目标是创建一 套完全自由的操作系统。为保证 GNU 软件可以自由的使用、复制、修改和发布,所有的 GNU 软件都

malloc double free behaviour

大城市里の小女人 提交于 2019-12-18 09:17:15
问题 The GNU manual page for malloc defines that when free() called twice with the same pointer (that was previously allocated by malloc() ) "undefined behaviour occurs". What kind of behaviour is that? Where can I find more Information about this kind of error? 回答1: "Undefined behavior" simply means that the implementation isn't required to deal with the situation in any particular way; any behavior or result is considered "correct". The result of free -ing a pointer more than once is up to the

How to use shell magic to create a recursive etags using GNU etags?

穿精又带淫゛_ 提交于 2019-12-18 01:03:35
问题 The standard GNU etags does not support a recursive walk of directories as done by exuberant ctags -R . If I only have access to the GNU etags, how can I use bash shell magic to get etags to produce a TAGS table for all the C++ files *.cpp and *.h files in the current directory and all directories below the current one recursively to create a TAGS table in the current directory which has the proper path name for emacs to resolve the TAGS table entries. 回答1: The Emacs Wiki is often a good

Linux: Block until a string is matched in a file (“tail + grep with blocking”)

混江龙づ霸主 提交于 2019-12-17 15:51:50
问题 Is there some one-line way in bash/GNU tools to block until there's a string matched in a file? Ideally, with timeout. I want to avoid multi-line loop. Update: Seems like I should have emphasize that I want the process to end when the string is matched. 回答1: Thanks both for answers, but the important part was that the process blocks until found, then ends. I found this: grep -q 'PATTERN' <(tail -f file.log) -q is not much portable, but I will only use Red Hat Enterprise Linux so it's ok. And

GNU parallel not working at all

笑着哭i 提交于 2019-12-17 05:00:56
问题 I have been trying to use GNU parallel for some time, but I have never been able to get it to function at all! For example, running (in a non-empty directory!): ls | parallel echo # Outputs single new line ls | parallel echo echo echo # Outputs three new lines. ls | parallel echo {} # /bin/bash: {}: command not found ls | parallel echo '{}' # /bin/bash: {}: command not found ls | parallel 'echo {}' # Outputs: {} ls | parallel -IMM 'echo MM' # Outputs: MM It seems that it is simply executing

GNU parallel not working at all

会有一股神秘感。 提交于 2019-12-17 05:00:16
问题 I have been trying to use GNU parallel for some time, but I have never been able to get it to function at all! For example, running (in a non-empty directory!): ls | parallel echo # Outputs single new line ls | parallel echo echo echo # Outputs three new lines. ls | parallel echo {} # /bin/bash: {}: command not found ls | parallel echo '{}' # /bin/bash: {}: command not found ls | parallel 'echo {}' # Outputs: {} ls | parallel -IMM 'echo MM' # Outputs: MM It seems that it is simply executing