bash
lieberstraum
这个作者很懒,什么都没留下…
展开
-
[awk] 一行命令处理文本的解析输出格式OFS
/* 简洁,推荐 */grep cpe Recent.xml|grep product |sort|awk -F '' '{ if($3!="") print $3 }'|awk '{print $1,$2,$3,$4}' FS=':' OFS=':'或 /*通用, 推荐*/grep cpe Recent.xml|grep product |sort|awk -F '' '{原创 2016-07-11 16:36:56 · 1040 阅读 · 0 评论 -
[awk]awk 与 shell的参数传递(双向)
1) 从bash传递匹配参数给awk:printf "Enter search pattern: "read patternawk "/$pattern/ "'{ nmatches++ } END { print nmatches, "found" }' /path/to/data或:printf "Enter search pattern: "re原创 2016-07-11 17:21:22 · 907 阅读 · 0 评论 -
bash 下 hash array的支持
declare -A region_URLsregion_URLs[beijing]="https://1.com"region_URLs[shanghai]="https://2.com"region_URLs[Sydney]="https://3.com"for site in "${!region_URLs[@]}"; do echo $site -原创 2016-04-08 15:00:02 · 470 阅读 · 0 评论 -
[bash] shell里简单输入文件的直接读取进行批处理rpmbuild
$cat samplesTree 3.2 1 bzip,opensslWallet 2007a 323 trousersperl-devel 2.6.33 7.3 glibc$cat import.shwhile read -r name version release requires; do echo $nam原创 2016-06-03 19:01:16 · 889 阅读 · 0 评论 -
[shell] getopts使用
#!/bin/bash# Usage: ./getopts.sh -d 3 -f file a b c d# $0 :命令本身,相当于C/C++中的argv[0]# $1 :第一个参数.$2,$3,... :类推。# $# 参数的个数,不包括命令本身# $@ :参数本身的列表,不包括命令# $* :和$@相同,但"$*"将所有的参数解释成一个字符串,而"$@"是一原创 2016-06-27 15:47:56 · 409 阅读 · 0 评论 -
[shell] 多进程脚本分析CVE数据库信息
参考链接: https://bg2bkk.github.io/post/shell%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%AE%9E%E8%B7%B5/$cat steps.shrm -r outputmkdir -p output#允许的进程数THREAD_MAX=24#$$是进程pidPfifo="/tmp/$$.fifo"mkf原创 2016-07-04 16:26:52 · 370 阅读 · 0 评论 -
[shell] kill 进程及子进程
kill -- -ppid找到要杀的进程的ppid:ps -eo pid,ppid,pgrp,session,comm原创 2016-07-04 19:02:34 · 1388 阅读 · 0 评论 -
[shell] 批量修改文件名
for i in `ls`; do j=`echo $i|awk -F '.' '{print $2}'`; mv $i $j; done原创 2016-07-07 16:27:02 · 302 阅读 · 0 评论 -
用一条语句执行mkdir和cd命令
$ vi .bash_profile function mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; } 其他:dirname=jack;mkdir dirname && cd dirname或者eval {mkdir,'&&'cd}\ jack转载 2016-08-18 11:21:22 · 1046 阅读 · 0 评论