sed

Linux常用命令大全

隐身守侯 提交于 2020-04-06 02:06:35
Linux常用命令大全(非常全!!!) 系统信息 arch 显示机器的处理器架构 uname -m 显示机器的处理器架构 uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络适配器及统计 cat /proc/mounts 显示已加载的文件系统 lspci -tv 罗列 PCI 设备 lsusb -tv 显示 USB 设备 date 显示系统日期 cal 2007 显示2007年的日历表 date 041217002007.00 设置日期和时间 - 月日时分年.秒 clock -w 将时间修改保存到 BIOS 关机 (系统的关机、重启以及登出 ) shutdown -h now 关闭系统 init 0 关闭系统 telinit 0 关闭系统 shutdown -h hours

凌许冬

北慕城南 提交于 2020-04-05 23:26:48
一.squid作为代理服务器使用;功能比较多;速度相对比较慢 二.varnish作为代理服务器,功能少;速度快性能高,缓存在数据在内存; 三.nginx 1.作为代理服务器 a.可以实现web集群的轮询访问,负载均衡 b.也可以根据web服务器性能的不同来设置相应的权重,从而发挥web集群最高性能; c.定时检查web集群的运行状态; 2.作为web服务器(不可以作JAVA的) a.实现用户访问一些重要网站,提供用户认证,确保信息安全; b.实现安全的web服务(https),确保网页安全; c.实现虚拟主机web;可以基于端口,域名,ip来实现虚拟web,使用比较灵活方便; d.实现web服务的动静分离,提供动态可读的网页,同时还可以读取数据库内容; e.实现页面的跳转 四.调度器 1.轮询 2.设置权重 3.设置失败次数,以及超时时间 五. 1.用户认证:访问指定网页,基于安全,需认证信息; 使用工具生成认证用户信息文件 修改配置文件,添加认证提示信息和指定文件 2.地址重写:当一些网站的域名发生改变时,或者网页路径改变时用户通过旧的网站信息依然可以正常访问; 六. sed -r 实现删除 修改 增加 替换 七.who 八.单引号:所见即所得,直接输出引号内的内容,不做任何变动 双引号:把引号内的内容输出出来,如果引号内有命令 变量 会先解析命令 变量的结果,然后

shell命令三剑客之sed命令详解

守給你的承諾、 提交于 2020-04-05 17:29:58
目录 1.初识sed命令 1.1 sed命令是什么 1.2 sed工作原理 1.3 sed 命令怎么用 1.4 示例 1.4.1 sed的n选项和编辑命令p的示例 1.4.2 sed的d编辑命令(不删除原文件内容)示例 1.4.3 sed的编辑命令之a追加命令示例 1.4.4 sed的编辑命令之i插入命令示例 1.4.5 sed的编辑命令之c替换命令示例 1.4.6 sed的编辑命令之r读入命令示例 1.4.7 sed的编辑命令之w写入命令示例(w命令不加-i也是直接修改原文件!) 1.4.8 sed的编辑命令之替换s命令示例 1.5 sed的s编辑命令可以使用任意分隔符作为定界符 1.6 sed 命令的-i 选项 1.7 sed的编辑命令补充之:G命令 1.8 sed命令特殊用法 1.9 sed的s命令中支持\t \n \s(正则里表示空白) 2 练习 shell中最核心的三个命令grep、sed、awk。 其中, grep:文本搜索。 sed:文本处理。 awk:文本分析工具、语言。 本文主要讲述sed命令的用法。 1.初识sed命令 1.1 sed命令是什么 sed是一种支持正则表达式的非交互式流编辑器。是脚本中修改文本或者文本替换的最佳工具。 1.2 sed工作原理 sed工作在内存,有两个空间: pattern space(模式空间):缓存空间,较多使用

sed - what is this curly brace notation called?

故事扮演 提交于 2020-04-05 15:37:40
问题 I just found this: sed '/label/{n;n;s/{}/{some comment}/;}' The intended effect is to seek label , proceed 2 lines down ( n;n; ) then substitute in ( s ) some comment . This is an amazing capability I never knew sed had. Would someone be kind enough to specify the name of this curly brace notation, and the name of the class of operators inside the braces? 回答1: Curly brackets allow to group several commands so that they are executed for the same address range (reference). The thing here is

sed - what is this curly brace notation called?

强颜欢笑 提交于 2020-04-05 15:34:09
问题 I just found this: sed '/label/{n;n;s/{}/{some comment}/;}' The intended effect is to seek label , proceed 2 lines down ( n;n; ) then substitute in ( s ) some comment . This is an amazing capability I never knew sed had. Would someone be kind enough to specify the name of this curly brace notation, and the name of the class of operators inside the braces? 回答1: Curly brackets allow to group several commands so that they are executed for the same address range (reference). The thing here is

Find and replace text in a file between range of lines using sed

眉间皱痕 提交于 2020-04-04 14:05:12
问题 I have a big text file (URL.txt) and I wish to perform the following using a single sed command: Find and replace text 'google' with 'facebook' between line numbers 19 and 33. Display the output on the terminal without altering the original file. 回答1: You can use SED's range selector for that: sed '19,33{s/google/facebook/}' file This will run the substitution on lines between 19 (exclusive) and 33 (inclusive) Note this will only replace the first occurrence of google on each line, you can

Find and replace text in a file between range of lines using sed

橙三吉。 提交于 2020-04-04 14:03:45
问题 I have a big text file (URL.txt) and I wish to perform the following using a single sed command: Find and replace text 'google' with 'facebook' between line numbers 19 and 33. Display the output on the terminal without altering the original file. 回答1: You can use SED's range selector for that: sed '19,33{s/google/facebook/}' file This will run the substitution on lines between 19 (exclusive) and 33 (inclusive) Note this will only replace the first occurrence of google on each line, you can

sed 命令详解

ぃ、小莉子 提交于 2020-04-03 22:14:55
sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。 sed的选项、命令、替换标记 命令格式 sed [options] 'command' file(s) sed [options] -f scriptfile file(s) 选项 -e<script>或--expression=<script>:以选项中的指定的script来处理输入的文本文件; -f<script文件>或--file=<script文件>:以选项中指定的script文件来处理输入的文本文件; -h或--help:显示帮助; -n或--quiet或——silent:仅显示script处理后的结果; -V或--version:显示版本信息。 参数 文件:指定待处理的文本文件列表。 sed命令 a\ 在当前行下面插入文本。 i\ 在当前行上面插入文本。 c\ 把选定的行改为新的文本。 d 删除,删除选择的行。 D 删除模板块的第一行。 s

shell_script1

倖福魔咒の 提交于 2020-04-02 07:32:55
1、简介 2、read 3、运算工具 4、if/then结构 5、while循环 6、for循环 一、简介 1、什么是shell shell是用户与系统交互作用的界面。shell是一种命令解释程序,同时也是一种高级程序设计语言 2、shell常见种类 Bourne Shell(/usr/bin/sh或/bin/sh) Bourne Again Shell(/bin/bash) C Shell(/usr/bin/csh) K Shell(/usr/bin/ksh) Shell for Root(/sbin/sh) 其中:Bash在日常工作中被广泛使用; 同时,Bash也是大多数Linux系统默认的Shell; 3、shell局限性 1.1、需要耗费大量资源的任务,特别是对执行速度要求较高的场合 1.2、涉及大量的数学计算 1.3.、关键性应用(数据库,网站等) 1.4.、设计图形或者GUI的应用 1.5.、需要直接访问硬件 1.6.、开发闭源的应用(相对于开源) 4、基础 文件系统:Linux 的文件系统是一个包含了目录和文件的分层的组织结构,位于最顶端的叫做根目录(root directory),用斜杠/ 来表示 目录: 是一种包含目录项的文件,每个目录项中都包含了文件名 文件名: 目录的内容称为目录项,目录项包含了文件名,只有两种字符不允许出现在文件名中:斜杠,空字符(ASCII

Linux三剑客 grep、awk、seed

佐手、 提交于 2020-03-30 19:39:05
简介 grep:适合单纯的查找或匹配文本 sed:适合编辑文本 awk:适合格式化文本,对文本进行复杂的格式化处理 1.grep   grep -help   【options】   -c:只输出匹配行的计数   -i:不区分大小写   -h:查询多文件是不显示文件名   -l:查询多文件时只输出包含匹配字符的文件名   -m:显示匹配行及行号   -s:不显示不存在或无匹配文本的错误信息   -v:显示不包含匹配文本的所有行   -color=auto:可以将找到的关键词部分加上颜色的显示   【pattern】正则参数含义   \:忽略正则表达式中特殊字符的原有含义   ^:匹配正则表达式的开始   $:匹配正则表达式的结束   \<:从匹配正则表达式的行开始   \>:到正则表达式的行结束   []:单个字符ex:[a]即a符合   [-]:范围ex:[a-c],即a,b,c符合   .:所有单个字符   *:有字符,长度可以为0   【简单使用】匹配的是当前文件夹下   grep ‘test’ d* 显示所有以d开头的文件中包含test的行   grep ‘test’ aa bb cc 显示在aa,bb,cc文件中匹配test的行   grep ‘[a-z]\{5\}’ aa 显示在aa文件中所有包含每个字符串至少有连续5个小写字符的字符串的行   grep 'w\(es\