![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
shell编程
gerrylon007
这个作者很懒,什么都没留下…
展开
-
linux命令之prlimit
命令介绍prlimit - get and set a process resource limits.prlimit 这个命令用来设置或者获取某进程的资源限制的.如临时设置某进程可打开的文件数,prlimit --pid=9999 --nofile=102400:102400, 这条命令表示设置pid为9999的进程的可打开的文件最大数改为102400(soft & hard).还有其他选项, 基本和ulimit一致:prlimit --help用法: prlimit [选项原创 2021-05-16 14:21:10 · 6295 阅读 · 0 评论 -
linux shell之合并多行为一行
需求将多行转为一行.如有个文件记录了一些人名$ cat a.txt alicebobdavidtomyang希望的输出为一行(方便人类阅读就可以):alice bob david tom yang 或者 alice,bob,david,tom,yang解决方法tr命令$ cat a.txt | tr '\n' ', ' | sed 's/,$//'alice,bob,david,tom,yangxargs命令$ cat a.txt | xargs alice b原创 2021-04-07 13:15:04 · 5451 阅读 · 0 评论 -
shell exec命令实现docker容器日志重定向到多个位置
exec 8<> >(tee -a /tmp/access.log); exec ./my-bin >&8 2>&1未完待续原创 2020-04-30 08:48:50 · 1234 阅读 · 0 评论 -
Linux shell "多线程"例子
shell多线程? 其实这里说的是多进程.其实就是开多个后台进程, 然后等它们都结束后, 才认为结束.举一个最常见的例子, ping一个网段内的所有ip, 看其通断情况. 其他情况都可以套用这个例子来改造:#! /bin/bash## Distributed under terms of the MIT license.## 这个并发度是为了同时不会开太多进程, 怕系统资源不够. ...原创 2020-04-06 10:06:02 · 362 阅读 · 0 评论 -
git commit hooks提示用户输入
今天定义git hook: prepare-commit-msg:意图是在用户提交时, 在commit msg后加一行: issue #${issueID}, 以此关联以redmine.#! /bin/sh ...原创 2020-03-27 18:53:17 · 812 阅读 · 0 评论 -
linux命令之exec
exec命令我已知有两种用法:用提供的命令替换当前shell, 其实就是子进程替换父进程创建/重定向文件描述符“用提供的命令替换当前shell”$ help execexec: exec [-cl] [-a name] [command [arguments …]] [redirection …]Replace the shell with the given command....原创 2020-01-21 16:31:04 · 714 阅读 · 0 评论 -
bash-utils项目启动,欢迎关注
写shell脚本断断续续也有1年了, 平时零零碎碎和写法一直没想起来整理.在github上开了个项目bash-utils, 收集一些常用的工具函数,命名方面和php的函数名称尽量保持一致.项目地址:https://github.com/GerryLon/bash-utils欢迎大家学习, 交流, 提PR!...原创 2019-10-18 13:18:51 · 193 阅读 · 0 评论 -
bash正则之BASH_REMATCH
偶然间发现了这个东西, 可以获取捕获组。如:[root@localhost ~]# [[ '123,456,abc,000' =~ ([0-9]+) ]][root@localhost ~]# echo ${BASH_REMATCH[1]}123可以看到, 只输出了一个匹配, 理论上来说共有3个。要输出所有的, 可以这样(来自: https://unix.stackexchange....原创 2019-09-29 18:01:23 · 8748 阅读 · 0 评论