grep

linux常用的命令语句

喜夏-厌秋 提交于 2020-03-17 03:49:49
Linux 下常用操作和命令 linux 目录架构 / 根目录 /bin 常用的命令 binary file 的目錄 /boot 存放系统启动时必须读取的档案,包括核心 (kernel) 在内 /boot/grub/menu.lst GRUB 设置 /boot/vmlinuz 内核 /boot/initrd 核心解壓縮所需 RAM Disk /dev 系统周边设备 /etc 系统相关设定文件 /etc/DIR_COLORS 设定颜色 /etc/HOSTNAME 设定用户的节点名 /etc/NETWORKING 只有 YES 标明网络存在 /etc/host.conf 文件说明用户的系统如何查询节点名 /etc/hosts 设定用户自已的 IP 与名字的对应表 /etc/hosts.allow 设置允许使用 inetd 的机器使用 /etc/hosts.deny 设置不允许使用 inetd 的机器使用 /etc/hosts.equiv 设置远端机不用密码 /etc/inetd.conf 设定系统网络守护进程 inetd 的配置 /etc/gateways 设定路由器 /etc/protocols 设定系统支持的协议 /etc/named.boot 设定本机为名字服务器的配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0 设置 IP /etc

大型网站架构——百万PV网站

给你一囗甜甜゛ 提交于 2020-03-17 01:04:03
实验架构: 黑线是正常情况数据的流向 红色是异常情况下数据流向 实验环境: CentOS7-1(master) 192.168.13.128 nginx反向代理(主)、redis缓存处理器(主)、mysql数据库(主) CentOS7-2(backup) 192.168.13.129 nginx反向代理(备)、redis缓存处理器(备)、mysql数据库(从) CentOS7-3(tomcat1) 192.168.13.130 tomcat(主) CentOS7-4(tomcat2) 192.168.13.131 tomcat(备) 1,安装部署nginx和keepalive服务(主备都需安装) [root@master ~]# systemctl stop firewalld.service ##关闭防火墙 [root@master ~]# setenforce 0 [root@master ~]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm ##安装nginx源 [root@master ~]# yum install -y keepalived nginx ##下载nginx和keepalive服务 [root

How do I use grep to extract a specific field value from lines

房东的猫 提交于 2020-03-16 05:31:40
问题 I have lines in a file which look like the following ....... DisplayName="john" .......... where .... represents variable number of other fields. Using the following grep command, I am able to extract all the lines which have a valid 'DisplayName' field: grep DisplayName="[0-9A-Za-z[:space:]]*" e:\test However, I wish to extract just the name (ie "john") from each line instead of the whole line returned by grep. I tried piping the output into the cut command but it does not accept string

How do I use grep to extract a specific field value from lines

自闭症网瘾萝莉.ら 提交于 2020-03-16 05:31:10
问题 I have lines in a file which look like the following ....... DisplayName="john" .......... where .... represents variable number of other fields. Using the following grep command, I am able to extract all the lines which have a valid 'DisplayName' field: grep DisplayName="[0-9A-Za-z[:space:]]*" e:\test However, I wish to extract just the name (ie "john") from each line instead of the whole line returned by grep. I tried piping the output into the cut command but it does not accept string

How do I use grep to extract a specific field value from lines

雨燕双飞 提交于 2020-03-16 05:30:59
问题 I have lines in a file which look like the following ....... DisplayName="john" .......... where .... represents variable number of other fields. Using the following grep command, I am able to extract all the lines which have a valid 'DisplayName' field: grep DisplayName="[0-9A-Za-z[:space:]]*" e:\test However, I wish to extract just the name (ie "john") from each line instead of the whole line returned by grep. I tried piping the output into the cut command but it does not accept string

How do I use grep to extract a specific field value from lines

血红的双手。 提交于 2020-03-16 05:30:13
问题 I have lines in a file which look like the following ....... DisplayName="john" .......... where .... represents variable number of other fields. Using the following grep command, I am able to extract all the lines which have a valid 'DisplayName' field: grep DisplayName="[0-9A-Za-z[:space:]]*" e:\test However, I wish to extract just the name (ie "john") from each line instead of the whole line returned by grep. I tried piping the output into the cut command but it does not accept string

使用grep时获取行号

大兔子大兔子 提交于 2020-03-15 12:29:30
我使用grep递归来搜索文件中的字符串,所有匹配的文件和包含该字符串的行都打印在终端上。 但是有可能获得这些线的行号吗? 例如:目前我得到的是 /var/www/file.php: $options = "this.target" ,但我想得到的是 /var/www/file.php: 1142 $options = "this.target"; , 1142 将是包含该字符串的行号。 我用来递归grep的语法是 sudo grep -r 'pattern' '/var/www/file.php' 还有一个问题是,我们如何得到不等于模式的结果。 像所有文件一样,但不是那些有特定字符串的文件? #1楼 如果您只想要行号,请执行以下操作: grep -nr Pattern file.ext | gawk '{print $1}' FS=":" 例: $ grep -nr 9780545460262 EXT20130410.txt | gawk '{print $1}' FS=":" 48793 52285 54023 #2楼 行号用 grep -n 打印: grep -n pattern file.txt 要仅获取行号(没有匹配的行),可以使用 cut : grep -n pattern file.txt | cut -d : -f 1 不 包含模式的行使用 grep -v 打印:

grep命令用法

拥有回忆 提交于 2020-03-15 10:16:02
linux grep命令 <div fc05="" fc11="" nbw-blog="" ztag="" js-fs2"=""> 1.作用 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来。grep全称是Global Regular Expression Print,表示全局正则表达式版本,它的使用权限是所有用户。 2.格式 grep [options] 3.主要参数 [options]主要参数: -c:只输出匹配行的计数。 -I:不区分大 小写(只适用于单字符)。 -h:查询多文件时不显示文件名。 -l:查询多文件时只输出包含匹配字符的文件名。 -n:显示匹配行及 行号。 -s:不显示不存在或无匹配文本的错误信息。 -v:显示不包含匹配文本的所有行。 pattern正则表达式主要参数: \: 忽略正则表达式中特殊字符的原有含义。 ^:匹配正则表达式的开始行。 $: 匹配正则表达式的结束行。 \<:从匹配正则表达 式的行开始。 \>:到匹配正则表达式的行结束。 [ ]:单个字符,如[A]即A符合要求 。 [ - ]:范围,如[A-Z],即A、B、C一直到Z都符合要求 。 。:所有的单个字符。 * :有字符,长度可以为0。 4.grep命令使用简单实例 $ grep ‘test’ d* 显示所有以d开头的文件中包含

linux grep命令

强颜欢笑 提交于 2020-03-15 10:15:16
主要参数 [options]主要参数: -c:只输出匹配行的计数。 -I:不区分大 小写(只适用于单字符)。 -h:查询多文件时不显示文件名。 -l:查询多文件时只输出包含匹配字符的文件名。 -n:显示匹配行及 行号。 -s:不显示不存在或无匹配文本的错误信息。 -v:显示不包含匹配文本的所有行。 pattern正则表达式主要参数: \: 忽略正则表达式中特殊字符的原有含义。 ^:匹配正则表达式的开始行。 $: 匹配正则表达式的结束行。 \<:从匹配正则表达 式的行开始。 \>:到匹配正则表达式的行结束。 [ ]:单个字符,如[A]即A符合要求 。 [ - ]:范围,如[A-Z],即A、B、C一直到Z都符合要求 。 .:所有的单个字符。 * :有字符,长度可以为0。 默认情况下,’grep’只搜索当前目录。如果 此目录下有许多 子目录 ,’grep’会以如下形式列出: grep: sound: Is a directory 这可能会使’grep’ 的输出难于阅读。这里有两种解决的办法: 明确要求搜索子目录:grep -r grep -w pattern files : 只匹配整个单词 ,而不是字符串的一部分(如匹配’magic’,而不是’magical’), 常用grep实例 (1)多个文件查询 grep "sort" *.doc #见文件名的匹配 (2)行匹配:输出匹配行的计数

如何升级CentOS 6.5下的MySQL

风格不统一 提交于 2020-03-15 03:35:28
如何升级CentOS 6.5下的MySQL CentOS 6.5自带安装了MySQL 5.1,但5.1有诸多限制,而实际开发中,我们也已经使用MySQL 5.6,这导致部分脚本在MySQL 5.1中执行会出错。我们只能升级MySQL 方法/步骤 1 备份数据库,升级MySQL通常不会丢失数据,但保险起见,我们需要做这一步。输入命令: mysqldump -u xxx -h xxx -P 3306 -p --all-databases > databases.sql 2 停止MySQL服务,输入命令: service mysqld stop 3 卸载旧版MySQL,输入命令: yum remove mysql mysql-* 执行过程中会询问你是否移除,此时输入“Y” 4 移除命令执行后,可再看看是否有残余的mysql,输入命令: yum list installed | grep mysql 如果有,可输入命令删除: rum remove mysql-libs 补充:如果以上方式还是卸载不干净那就参考下面的卸载方式,一般就可以卸载干净了 1、yum方式安装的mysql 1、yum remove mysql mysql-server mysql-libs compat-mysql51 2、rm -rf /var/lib/mysql 3、rm /etc/my.cnf