grep

in vim, how to set “args” to the result of a “grep -l”?

为君一笑 提交于 2020-02-19 09:46:53
问题 To illustrate, here's how to do it from the command-line: vim `grep "hello" * -Rl` This opens vim with all the files that have "hello" in them (-l gives the filenames alone). I want to do the same thing, but from within vim. Conceptually, something like this (which doesn't work): :args !grep "hello" * -Rl I'm open to completely different approaches to achieve this; I'd just like it to be on one line (so it's easy to edit and redo). The answer is to simply use backticks - but with a key

how to search for a particular string from a .gz file?

点点圈 提交于 2020-02-19 09:35:03
问题 I want to search for a particular string from a .gz file containing a text file without extracting in linux terminal. I know how to search for a string from a text file using grep "text to search" ./myfile.txt . But how to make it work for .gz files? 回答1: gunzip -c mygzfile.gz | grep "string to be searched" But this would only work if the .gz file contains text file which is true in your case. 回答2: You can use zgrep. Usage is similar to grep . zgrep "pattern" file.gz From the man page's

how to search for a particular string from a .gz file?

一个人想着一个人 提交于 2020-02-19 09:33:11
问题 I want to search for a particular string from a .gz file containing a text file without extracting in linux terminal. I know how to search for a string from a text file using grep "text to search" ./myfile.txt . But how to make it work for .gz files? 回答1: gunzip -c mygzfile.gz | grep "string to be searched" But this would only work if the .gz file contains text file which is true in your case. 回答2: You can use zgrep. Usage is similar to grep . zgrep "pattern" file.gz From the man page's

Linux实战教学笔记40: Mha-Atlas-MySQL高可用方案实践(二)

你说的曾经没有我的故事 提交于 2020-02-18 07:11:06
六,配置VIP漂移 主机名 IP地址(NAT) 漂移VIP 描述 mysql-db01 eth0:192.168.0.51 VIP:192.168.0.60 系统:CentOS6.5(6.x都可以) 安装:mysql5.6 mysql-db02 eth0:192.168.0.52 VIP:192.168.0.60 系统:CentOS6.5(6.x都可以) 安装:mysql5.6 mysql-db03 eth0:192.168.0.53 VIP:192.168.0.60 系统:CentOS6.5(6.x都可以) 安装:mysql5.6 6.1 IP漂移的两种方式 通过keepalived的方式,管理虚拟IP的漂移 通过MHA自带脚本方式,管理虚拟IP的漂移 6.2 MHA脚本管理方式 (1)获取管理脚本master_ip_failover 提示:yum安装的manager是没有这个脚本的。 我们需要从manager的源码包里复制一个。 [root@mysql-db03 ~]# ll mha4mysql-manager-0.56.tar.gz -rw-r--r--. 1 root root 113914 Sep 4 18:43 mha4mysql-manager-0.56.tar.gz [root@mysql-db03 ~]# tar xf mha4mysql-manager-0.56

shell之活学活用

。_饼干妹妹 提交于 2020-02-16 17:40:39
1. 查看系统运行级别 [root@localhost ~]# runlevel N 5 [root@localhost ~]# runlevel |cut -c3 5 [root@localhost ~]# runlevel |cut -d' ' -f2 5 [root@localhost ~]# 2. 查看系统ip等信息 [root@localhost ~]# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.25.254.10 netmask 255.255.255.0 broadcast 172.25.254.255 inet6 fe80::5054:ff:fe00:80a prefixlen 64 scopeid 0x20<link> ether 52:54:00:00:08:0a txqueuelen 1000 (Ethernet) RX packets 13769 bytes 2221738 (2.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 8056 bytes 1276337 (1.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0

the-art-of-command-line 2019-02-15

末鹿安然 提交于 2020-02-15 18:38:02
命令行的艺术 前言 基础 日常使用 文件及数据处理 系统调试 单行脚本 冷门但有用 仅限 OS X 系统 仅限 Windows 系统 更多资源 免责声明 熟练使用命令行是一种常常被忽视,或被认为难以掌握的技能,但实际上,它会提高你作为工程师的灵活性以及生产力。本文是一份我在 Linux 上工作时,发现的一些命令行使用技巧的摘要。有些技巧非常基础,而另一些则相当复杂,甚至晦涩难懂。这篇文章并不长,但当你能够熟练掌握这里列出的所有技巧时,你就学会了很多关于命令行的东西了。 这篇文章是 许多作者和译者 共同的成果。 这里的部分内容 首次 出现 于 Quora , 但已经迁移到了 Github,并由众多高手做出了许多改进。 如果你在本文中发现了错误或者存在可以改善的地方,请 贡献你的一份力量 。 前言 涵盖范围: 这篇文章不仅能帮助刚接触命令行的新手,而且对具有经验的人也大有裨益。本文致力于做到 覆盖面广 (涉及所有重要的内容), 具体 (给出具体的最常用的例子),以及 简洁 (避免冗余的内容,或是可以在其他地方轻松查到的细枝末节)。在特定应用场景下,本文的内容属于基本功或者能帮助您节约大量的时间。 本文主要为 Linux 所写,但在 仅限 OS X 系统 章节和 仅限 Windows 系统 章节中也包含有对应操作系统的内容。除去这两个章节外,其它的内容大部分均可在其他类 Unix 系统或

linux查找某进程id并杀掉

痞子三分冷 提交于 2020-02-14 18:04:23
#!/bin/sh tomcat_id=$(ps -ef | grep tomcat | grep -v "grep" | awk '{print $2}') for tomcatid in $tomcat_id do kill -9 ${tomcatid} echo "killed tomcat_id $tomcatid" done sh /data/4a/tomcat/bin/startup.sh echo "restart tomcat..." #"--------4a--------"tomcat_id=$(ps -ef | grep tomcat | grep -v "grep" | awk '{print $2}')for tomcatid in $tomcat_iddo kill -9 ${tomcatid} echo "killed tomcat_id $tomcatid" donesh /data/4a/tomcat/bin/startup.shecho "restart tomcat..." 来源: https://www.cnblogs.com/xiaoliu66007/p/12308179.html

Linux 常用命令

对着背影说爱祢 提交于 2020-02-14 04:16:24
less  常用来查看日志,less xxx.log。常用参数如下: G 跳转到最后一行 gg 跳转到第一行 u up-上翻半页 d down-下翻半页 ? 向上查找内容 / 向下查找内容 n next-继续查找 N 反向继续查找 -N 显示行号 10g 跳到第10行 netstat  查看网络状态,常配合 grep 命令一起使用。例如:netstat -utlnp | grep 端口号,netstat -utlnp | grep 进程号。 -t 查看 tcp 连接 -u 查看 udp 连接 -l 查看监听状态的连接 -n 显示端口 -p 显示进程号(权限不足时不会显示) top  监控系统状态,类似于 windows 中的任务管理器。 M 按照内存占用大小,降序排列 P 按照CPU占用率,降序排列 查找文件  find 目录 -name "文件名称" 进程 ps -ef | grep xxx 查看进程号 pwdx pid 查看进程启动时的工作目录 来源: https://www.cnblogs.com/lighter-blog/p/11807710.html

How to grep asterisk without escaping?

爷,独闯天下 提交于 2020-02-13 10:25:36
问题 Suppose I have a file abc.txt which contains line ab*cd . When I grep that pattern ab*cd with quotes but without escaping the asterisk it does not work: > grep ab*c abc.txt > grep "ab*c" abc.txt > grep 'ab*c' abc.txt When I use both quotes and escaping it does work > grep "ab\*c" abc.txt ab*cd > grep 'ab\*c' abc.txt ab*cd Now I wonder why the quotes do not work and if I can use only quotes without escaping the asterisk. 回答1: Use the flag -F to search for fixed strings -- instead of regular

阿里云部署前后台项目

柔情痞子 提交于 2020-02-13 10:22:08
# 阿里云部署前台项目 一、远程连接阿里云服务器 1、VNC模式接入 点击实例名称,进入实例配置页面 远程连接选择VNC模式() 输入远程连接密码,进入远程操作界面 2、本地cmd命令行连接 win + r 输入cmd进入dos操作界面 输入 ssh root@47.99.240.172,登入远程服务器 根据提示输入密码,进入远程操作界面 cd ~ 进入home目录层 cd / && ls 查看当前目录下文件状态 二、创建密钥(避免多实例时多次输入账号密码) 1、命令行方式 本地.ssh文件夹中生成密钥对 ssh-keygen -t rsa -f admin-key 本地admin-key.pub复制到服务器中 scp ./admin-key.pub root@47.99.240.172:~/.ssh 删除本地公钥 rm -f admin-key.pub 新建config文件 touch config vim config 编辑config内容 Host admin HostName 47.99.240.172 port 22 User root IdentityFile ~/.ssh/admin-key 服务器中配置 将admin-key.pub内容追加到~/.ssh/authorized_keys文件中 cat ~/admin-key.pub >> ~/.ssh