我是否正确地假设ulimit -c 0
将核心文件创建的最大大小设置为无限制(不受约束、无限制)的值?
我尝试过的 Linux 发行版 Bash(Rocky Linux 8.10、9.5、Ubuntu)中,甚至在 macOS 中运行的 Bash 5.2.37 中,都提到了ulimit -c unlimited
但没有提到 0 或“无限”。在 macOS 上的 zsh 5.9 下,提到了和,但没有提到 0。help ulimit
run-help ulimit
unlimited
hard
我是否正确地假设ulimit -c 0
将核心文件创建的最大大小设置为无限制(不受约束、无限制)的值?
我尝试过的 Linux 发行版 Bash(Rocky Linux 8.10、9.5、Ubuntu)中,甚至在 macOS 中运行的 Bash 5.2.37 中,都提到了ulimit -c unlimited
但没有提到 0 或“无限”。在 macOS 上的 zsh 5.9 下,提到了和,但没有提到 0。help ulimit
run-help ulimit
unlimited
hard
我想知道是否可以编写一个符合 POSIX 的find
脚本,根据其参数构建命令。
另一篇 SE文章解释了如何对 Bash(和 zsh)执行此操作,但它使用了特定于 bash(或 zsh)的工具。
最初的问题是能够构建这样的查找命令:
find -iname '*foo*' -o -iname '*bar*' -o -iname '*blah*'
答案是以下 Bash 脚本代码:
findany() {
local args=('-iname' "*$1*")
shift
while [ "$#" -gt 0 ]; do
args+=('-o' '-iname' "*$1*")
shift
done
find . "${args[@]}"
}
是否可以在符合 POSIX 的脚本中执行类似操作?
我想要翻译:
"a b c syscall=257 success=yes"
改为:
"a b c syscall=openat success=yes"
我喜欢使用sed组捕获正则表达式和替换,并结合使用 ausyscall 应用于正则表达式组提取的数字。
我在 Linux/bash 下尝试了以下操作:
echo "a b c syscall=257 success=yes" |
sed -e "s:syscall=\([0-9]*\):SYSCALL="$(ausyscall 257)":"
它打印:a b c SYSCALL=openat success=yes
正如预期的那样。
然后我尝试使用捕获组 #1 作为 的参数ausyscall
。像这样:
echo "a b c syscall=257 success=yes" |
sed -e "s:syscall=\([0-9]*\):SYSCALL="$(ausyscall \1)":"
这将调用ausyscall 1
which 打印write
。这不是捕获的组 #1(其值为 257)。
因此我尝试使用\\1
,但也失败了:
echo "a b c syscall=257 success=yes" |
sed -e "s:syscall=\([0-9]*\):SYSCALL="$(ausyscall \\1)":"
这将调用失败,在 stderr( )ausyscall \1
上打印错误并在 stdout 上打印。Unknown syscall \1 using x86_64 lookup table
a b c SYSCALL= success=yes
无法将捕获的值传递给 ausyscall。我尝试使用单引号,但无法调用 ausyscall。
可以这样使用sed吗?
使用sed可以实现吗?如果可以,我遗漏了什么?