本文目标是仅使用内置功能记录一些常用的完成各种任务的方法。 "前言" "其他" "安装家目录" 前言 外部流程和程序的替代方案集合。脚本语言比人们意识到的更强大,大多数任务都可以在不依赖外部程序的情况下完成。调用外部程序是昂贵的,过度使用将会导致程序运行明显的缓慢。使用内置方法编写的脚本将更快,需要 ...
转载
2021-09-15 11:52:00
101阅读
2评论
统计文本里单词出现的次数命令: cat my.txt | tr -cs A-Za-z '\n'|tr A-Z a-z|sort| uniq -c统计交换内存的占用情况命令:top -n 1|grep Swap|sed 's;k.*;;'|awk&nb
原创
2014-02-12 15:18:04
1186阅读
1、优先级从-20到19。越大,优先级越低。 2、nice 可以在创建进程时,为进程指定谦让度(优先级)的增量值,进程的优先级的值是父进程SHELL的优先级的值与我们所指定谦让度的相加和。 3、示例 1)nice nice -n 5 gaim & //运行gaim程序,并为它指定谦让度增量为5; nice -n 谦让度的增量值 程序 2)ren...
转载
2011-09-27 16:03:00
101阅读
2评论
1、说明 top 选择参数 2、option ① -b 以批量模式运行,但不能接受命令行输入; ② -c 显示命令行,而不仅仅是命令名; ③ -d N 显示两次刷新时间的间隔,比如 -d 5,表示两次刷新间隔为5秒; ④ -i 禁止显示空闲进程或僵尸进程; ⑤ -n NUM 显示更新次数,然后退出。如-n 5,top更新5次数据退出; ⑥...
转载
2011-09-27 15:48:00
104阅读
2评论
1、pgrep 是通过程序的名字来查询进程的工具,一般是用来判断程序是否正在运行。 2、说明 pgrep 参数选项 程序名 look up processes based on name and other 3、option ① -l 列出程序名和进程ID; ② -o 进程起始的ID; ③ -n 进程终止的ID; 4、示例 pg...
转载
2011-09-27 15:15:00
90阅读
2评论
1、说明 report a snapshot of the current processes. ps [options] 2、常用option ① l 长格式输出; ② u 按用户名和启动时间的顺序来显示进程; ③ j 用任务格式来显示进程; ④ f 用树形格式来显示进程; ⑤ a/e 显示所有用户的所有进程(包括其它用户); ...
转载
2011-09-27 14:56:00
78阅读
2评论
1、head - output the first part of files head [OPTION]... [FILE]... 2、option ① -c, --bytes=[-]N:print the first N bytes of each file; ② -n, --lines=[-]N:print the first N lines instead of the fi...
转载
2011-10-31 08:32:00
73阅读
2评论
1、tail - output the last part of files tail [OPTION][+/-num]... [FILE]... 2、option ① -f,:output appended data as the file grows; ② -s, :with -f, sleep for S seconds (default 1.0) betwe...
转载
2011-10-31 08:23:00
71阅读
2评论
场景:一般命令的输出都会显示在终端中,有些时候需要将一些命令的执行结果想要保存到文件中进行后续的分析/统计,则这时候需要使用到的输出重定向技术。 >:覆盖输出,会覆盖掉原先的文件内容 >>:追加输出,不会覆盖原始文件内容,会在原始内容末尾继续添加 2>:错误输出,会覆盖掉原先的文件内容 2>>:错误
转载
2019-07-10 16:15:00
52阅读
列出你最常用的10条shellhistory | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | headhistory | awk '{a[$4]++}END{for(i in a){print a[$i] " " i}}' | sort -rn | head grep -
原创
2015-09-15 12:50:34
335阅读
阅读目录shell 脚本统计当前并发连接数shell 脚本统计当前并发连接数netstat -pnt | grep :80 | grep ESTABLISHED | wc -l
原创
2023-02-09 11:15:08
16阅读
简单的shell脚本应用。
原创
2017-04-11 15:01:14
589阅读
shell debug模式
原创
2022-05-19 10:12:18
119阅读
1、说明 cut [option] files cut -d'分隔字元' -f fields 取出分字段的文件的某些特定字段 2、options -d:用来定义分隔符,默认为tab键,与-f一起使用 -f:需要取得哪个字段,根据-d的分隔字段 -c:以字符 (characters) 为單位取出固定字元區間;-c后面的值指定从第几个字符开始输出。 ...
转载
2011-09-26 11:39:00
100阅读
2评论
通常,使用 cmp 命令比较非文本文件,使用 diff 命令比较文本文件。diff比较并显示文件中那些行不同,cmp比较并显示一行中那些字符不同。 1、说明 1)比较两个文件的内容并报告不同的第一个字符。 cmp [ -l | -s ] File1 File2 若不指定任何文件名称或是所给予的文件名为”-”,则cmp指令会从标准输入设备读取数据。 2)option -l 对...
转载
2011-09-26 10:08:00
138阅读
2评论
1、diff 1)Name diff - find differences between two files Synopsis diff [options] from-file to-file Description In the simplest case, diff compares the contents of the two files fr...
转载
2011-09-26 09:41:00
101阅读
2评论
操作:导入模块subprocessimportsubprocesszhi=subprocess.getoutput('ls')1.subprocess模块中的常用函数函数描述subprocess.run()Python3.5中新增的函数。执行指定的命令,等待命令执行完成后返回一个包含执行结果的CompletedProcess类的实例。subprocess.call()执行指定的命令,返回命令执行状
原创
2019-10-24 16:47:29
355阅读
1、说明 NAME sort–sort lines of text files SYNOPSIS sort [OPTION]…[FILE]… DESCRIPTION Write sorted concatenation of all FILE(s) to standard output. 选项 ...
转载
2011-09-26 00:01:00
101阅读
2评论
1、说明 split [-bl] file PREFIX 2、option 参数: -b:后面可接欲分割成的档案大小,可加单位,例如 b, k, m 等; -l:以行数来进行分割。 PREFIX :代表前置字元的意思,可作為分割檔案的前導文字。 3、示例 1)split -b 30b prime.cpp me 2)split -l 20 ...
转载
2011-09-26 11:10:00
82阅读
2评论
1、mkdir-m, --mode=MODE set file mode (as in chmod), not a=rwx - umask-p, --parents no error if existing, make parent directories as neededmkdir -p DIR1/DIR2 //如果dir1不存在,也创建dir1mkdir -m 755 /usr/dir3 //并设置mode2、rmdir-p, --parents remove DIRECTORY and its ancestors; e.g., `rmdir -p a/b/c' is simil
转载
2011-09-27 19:21:00
72阅读
2评论