小编msc*_*lli的帖子

如何绕过Linux"Too Many Arguments"限制

我必须将256Kb的文本作为参数传递给"aws sqs"命令,但是在命令行中运行的限制大约为140Kb.这在许多地方已经讨论过,它已经在Linux内核中从2.6.23内核中解决了.

但无法让它发挥作用.我在用3.14.48-33.39.amzn1.x86_64

这是一个简单的测试示例:

#!/bin/bash

SIZE=1000
while [ $SIZE -lt 300000 ]
do
   echo "$SIZE"
   VAR="`head -c $SIZE < /dev/zero | tr '\0' 'a'`"
   ./foo "$VAR"
   let SIZE="( $SIZE * 20 ) / 19"
done
Run Code Online (Sandbox Code Playgroud)

foo剧本只是:

#!/bin/bash
echo -n "$1" | wc -c
Run Code Online (Sandbox Code Playgroud)

而我的输出是:

117037
123196
123196
129680
129680
136505
./testCL: line 11: ./foo: Argument list too long
143689
./testCL: line 11: ./foo: Argument list too long
151251
./testCL: line 11: ./foo: Argument list too …
Run Code Online (Sandbox Code Playgroud)

linux shell amazon-sqs

5
推荐指数
1
解决办法
3113
查看次数

在 HTML 输出的 [R]Markdown 数学表达式中插入不间断空格

我正在 bookdown 中撰写科学报告,我想使用不间断空格作为遵循SI/ISO 31-0 标准的千位分隔符。

\n\n

实际上,我更喜欢不间断的细空格U+202F/ &#8239;),但为了简单起见,让我们在这里考虑U+00A0/ 。&nbsp;

\n\n

我设置了一个knitr钩子来动态执行此操作:

\n\n
knitr::knit_hooks$set(inline=function(output)\n                               ifelse(is.numeric(output),\n                                      prettyNum(round(output, 1),\n                                                big.mark=\'&nbsp;\'),\n                                      output))\n
Run Code Online (Sandbox Code Playgroud)\n\n

只要我不在数学表达式中使用任何返回数值输出 > 999 的内联 R 表达式,这就会按预期工作。

\n\n

下面的 Bookdown MWE 说明了这个问题:

\n\n
---\noutput:\n  bookdown::html_document2: default\n---\n```{r set-output-hook, include=FALSE}\nknitr::knit_hooks$set(inline=function(output)\n                               ifelse(is.numeric(output),\n                                      prettyNum(round(output, 1),\n                                                big.mark=\'&nbsp;\'),\n                                      output))\n```\n\nThis works:\nThe product of $\\pi$ and `r 1000` is `r pi*1000`.\n\nThis fails to render: \n$\\pi\\cdot`r 1000`=`r pi*1000`$\n\nThis renders but is cumbersome as it requires me to …
Run Code Online (Sandbox Code Playgroud)

markdown mathjax pandoc r-markdown bookdown

5
推荐指数
1
解决办法
4582
查看次数

使每一行双vim

我有一个看起来像这样的文件:

file1
file2
file3
.
.
.
filen
Run Code Online (Sandbox Code Playgroud)

我想将其转换为:

echo "file1"
cat file1
echo "file2"
cat file2
.
.
.
.
echo "filen"
cat filen
Run Code Online (Sandbox Code Playgroud)

一种方法是使用for循环并读取原始文件的内容并将修改后的内容写入另一个文件,我这样做并且它有效.是否有任何命令在vim通过:g或任何其他命令中执行相同的操作?

vi vim shell

4
推荐指数
1
解决办法
838
查看次数

C hsearch发现之前未输入的值

这是这个问题的后续问题.

由于我解决了部分内容并且我觉得剩下的问题与第一个问题无关,所以我决定将这两个部分分成两个问题.

我已经使用POSIX hcreate/ 实现了一个关联数组hsearch,如此处所示.

为了完整起见,以下是除main()上一个问题的函数之外的所有代码:

#include <inttypes.h> /* intptr_t             */
#include <search.h>   /* hcreate(), hsearch() */
#include <stdio.h>    /* perror()             */
#include <stdlib.h>   /* exit()               */
#include <string.h>   /* strcpy()             */

void exit_with_error(const char* error_message){
  perror(error_message);
  exit(EXIT_FAILURE);
}
int fetch(const char* key, intptr_t* value){
  ENTRY e,*p;
  e.key=(char*)key;
  p=hsearch(e, FIND);
  if(!p) return 0;
  *value=(intptr_t)p->data;
  return 1;
}

void store(const char *key, intptr_t value){
  ENTRY e,*p;
  e.key=(char*)key;
  p …
Run Code Online (Sandbox Code Playgroud)

c posix associative-array

3
推荐指数
1
解决办法
195
查看次数

如何在dplyr中将NAs排在第一位?

请考虑以下示例:

require(tibble)
require(dplyr)

set.seed(42)

tbl <- data_frame(id = letters[1:10], val = c(runif(5), NA, runif(4)))

tbl
Run Code Online (Sandbox Code Playgroud)
# A tibble: 10 × 2
      id          val
   <chr>        <dbl>
1      a 0.9148060435
2      b 0.9370754133
3      c 0.2861395348
4      d 0.8304476261
5      e 0.6417455189
6      f           NA
7      g 0.5190959491
8      h 0.7365883146
9      i 0.1346665972
10     j 0.6569922904
Run Code Online (Sandbox Code Playgroud)

我想排序tibbleval,把NA第一个:

tbl %>%
  arrange(val)
Run Code Online (Sandbox Code Playgroud)
# A tibble: 10 × 2
      id          val
   <chr>        <dbl>
1      i 0.1346665972
2      c …
Run Code Online (Sandbox Code Playgroud)

sorting r na dplyr

2
推荐指数
1
解决办法
516
查看次数

标签 统计

shell ×2

amazon-sqs ×1

associative-array ×1

bookdown ×1

c ×1

dplyr ×1

linux ×1

markdown ×1

mathjax ×1

na ×1

pandoc ×1

posix ×1

r ×1

r-markdown ×1

sorting ×1

vi ×1

vim ×1