grep

ubuntu命令大全

不羁的心 提交于 2020-01-20 10:20:04
查看软件xxx安装内容 dpkg -L xxx 查找软件库中的软件 apt-cache search 正则表达式 查找软件库中的软件 aptitude search 软件包 查找文件属于哪个包 dpkg -S filename 查找文件属于哪个包 apt-file search filename 查询软件xxx依赖哪些包 apt-cache depends xxx 查询软件xxx被哪些包依赖 apt-cache rdepends xxx 增加一个光盘源 sudo apt-cdrom add 系统升级 sudo apt-get update;sudo apt-get dist-upgrade 清除已删除包的残馀配置文件 dpkg -l |grep ^rc|awk ‘{print $2}’ |sudo xargs dpkg -P 编译时缺少h文件的自动处理 sudo auto-apt run ./configure 查看安装软件时下载包的临时存放目录 ls /var/cache/apt/archives 备份当前系统安装的所有包的列表 dpkg –get-selections | grep -v deinstall > ~/somefile 从备份的安装包的列表文件恢复所有包 dpkg –set-selections < ~/somefile;sudo dselect

grep -f maximum number of patterns?

↘锁芯ラ 提交于 2020-01-20 05:07:06
问题 I'd like to use grep on a text file with -f to match a long list (10,000) of patterns. Turns out that grep doesn't like this (who, knew?). After a day, it didn't produce anything. Smaller lists work almost instantaneously. I was thinking I might split my long list up and do it a few times. Any idea what a good maximum length for the pattern list might be? Also, I'm rather new with unix. Alternative approaches are welcome. The list of patterns, or search terms, are in a plaintext file, one per

grep -f maximum number of patterns?

倖福魔咒の 提交于 2020-01-20 05:05:26
问题 I'd like to use grep on a text file with -f to match a long list (10,000) of patterns. Turns out that grep doesn't like this (who, knew?). After a day, it didn't produce anything. Smaller lists work almost instantaneously. I was thinking I might split my long list up and do it a few times. Any idea what a good maximum length for the pattern list might be? Also, I'm rather new with unix. Alternative approaches are welcome. The list of patterns, or search terms, are in a plaintext file, one per

linux去除空行的方法

和自甴很熟 提交于 2020-01-19 14:16:40
1、grep grep . data.txt grep -v '^$' data.txt grep '[^$]' data.txt 2、sed sed -i '/^$/d' data.txt sed -i '/^\s*$/d' data.txt #这个命令还可将完全空格、tab等组成的空行删掉。 3、awk awk NF data.txt # 这个也可以将空格、tab等组成的空行删掉。 awk '!/^$/' data.txt tr - s'\n'< data.txt 来源: CSDN 作者: zsj.python之路 链接: https://blog.csdn.net/zhangshuaijun123/article/details/104036924

zabbix3.2使用自带模板监控MySql

不问归期 提交于 2020-01-18 18:30:53
一、zabbix自带MySql模板监控项 Zabbix3.0之后已经有MySql监控模板了,所以我们只要引用ZabbixServer自带的模板即可。zabbix默认有14个监控项 我们只需获取监控项需要的值就ok,而这些值大部分可以通过mysqladmin命令获取 二、编写脚本获取mysql性能指标数据 vim chk_mysql.sh vim chk_mysql.sh # 用户名 #MYSQL_USER='zabbix' # 密码 #MYSQL_PWD='zabbix' #在脚本中输入密码mysql会提示安全告警信息#Warning: Using a password on the command line interface can be #insecure,需要将帐号密码等配置添加到mysql配置文件my.cnf中即可,脚本中#不用输入账号密码 # 主机地址/IP MYSQL_HOST='127.0.0.1' # 端口 MYSQL_PORT='3306' # 数据连接 MYSQL_CONN="/usr/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PWD} -h${MYSQL_HOST} -P${MYSQL_PORT}" # 参数是否正确 if [ $# -ne "1" ];then echo "arg error!" fi # 获取数据

find xargs grep查找文件及文件内容

感情迁移 提交于 2020-01-18 16:06:37
1,在某个路径下查文件。 在/etc下查找“*.log”的文件 find /etc -name “*.log” 2,扩展,列出某个路径下所有文件,包括子目录。 find /etc -name “*” 3,在某个路径下查找所有包含“hello abcserver”字符串的文件。 find /etc -name "*" | xargs grep "hello abcserver" 或者 find /etc -name “*” | xargs grep “hello abcserver” > ./cqtest.txt 作者:Joncc 链接:https://www.jianshu.com/p/94f46ddc24a9 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 来源: https://www.cnblogs.com/arci/p/12209160.html

每天一个linux命令(1):ls命令

拥有回忆 提交于 2020-01-18 14:03:03
每天一个linux命令(1):ls命令 ls命令是linux下最常用的命令。ls命令就是list的缩写缺省下ls用来打印出当前目录的清单如果ls指定其他目录那么就会显示指定目录里的文件及文件夹清单。 通过ls 命令不仅可以查看linux文件夹包含的文件而且可以查看文件权限(包括目录、文件夹、文件权限)查看目录信息等等。ls 命令在日常的linux操作中用的很多! 1. 命令格式: ls [选项] [目录名] 2. 命令功能: 列出目标目录中所有的子目录和文件。 3. 常用参数: -a, –all 列出目录下的所有文件,包括以 . 开头的隐含文件 -A 同-a,但不列出“.”(表示当前目录)和“..”(表示当前目录的父目录)。 -c 配合 -lt:根据 ctime 排序及显示 ctime (文件状态最后更改的时间)配合 -l:显示 ctime 但根据名称排序否则:根据 ctime 排序 -C 每栏由上至下列出项目 –color[=WHEN] 控制是否使用色彩分辨文件。WHEN 可以是'never'、'always'或'auto'其中之一 -d, –directory 将目录象文件一样显示,而不是显示其下的文件。 -D, –dired 产生适合 Emacs 的 dired 模式使用的结果 -f 对输出的文件不进行排序,-aU 选项生效,-lst 选项失效 -g 类似 -l

linux 下查看机器是cpu是几核的

允我心安 提交于 2020-01-18 09:06:14
linux 下查看机器是cpu是几核的 几个cpu more /proc/cpuinfo |grep "physical id"|uniq|wc -l 每个cpu是几核(假设cpu配置相同) more /proc/cpuinfo |grep "physical id"|grep "0"|wc -l cat /proc/cpuinfo | grep processor 1. 查看物理CPU的个数 #cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l 2. 查看逻辑CPU的个数 #cat /proc/cpuinfo |grep "processor"|wc -l 3. 查看CPU是几核 #cat /proc/cpuinfo |grep "cores"|uniq 4. 查看CPU的主频 #cat /proc/cpuinfo |grep MHz|uniq # uname -a Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux (查看当前操作系统内核信息) # cat /etc/issue | grep Linux Red Hat Enterprise Linux AS release 4 (Nahant

查看linux中的TCP连接数

两盒软妹~` 提交于 2020-01-18 03:49:04
一、查看哪些IP连接本机 netstat -an 二、查看TCP连接数 1)统计80端口连接数 netstat -nat|grep -i "80"|wc -l 2)统计httpd协议连接数 ps -ef|grep httpd|wc -l 3)、统计已连接上的,状态为“established netstat -na|grep ESTABLISHED|wc -l 4)、查出哪个IP地址连接最多,将其封了. netstat -na|grep ESTABLISHED|awk {print $5}|awk -F: {print $1}|sort|uniq -c|sort -r +0n netstat -na|grep SYN|awk {print $5}|awk -F: {print $1}|sort|uniq -c|sort -r +0n --------------------------------------------------------------------------------------------- 1、查看apache当前并发访问数: netstat -an | grep ESTABLISHED | wc -l 对比httpd.conf中MaxClients的数字差距多少。 2、查看有多少个进程数: ps aux|grep httpd|wc -l 3

使用正则表达式

前提是你 提交于 2020-01-18 03:19:34
4案例4:使用正则表达式 4.1问题 本案例要求熟悉正则表达式的编写,完成以下任务: 利用egrep工具练习正则表达式的基本用法 4.2方案 4.3步骤 实现此案例需要按照如下步骤进行 步骤一:正则表达式匹配练习 1)典型的应用场合:grep、egrep检索文本行 grep命令不带-E选项时,支持基本正则匹配模式。比如"word"关键词检索、"^word"匹配以Word开头的行、"word$"匹配以word结尾的行......等等。 输出以"r"开头的用户记录: [root@svr5 ~]# grep '^r' /etc/passwd root:x:0:0:root:/root:/bin/bash rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin 输出以"localhost"结尾的行: [root@svr5 ~]# grep 'localhost$' /etc/hosts 127.0.0.1 localhost.localdomain localhost 若希望在grep检索式同时组合多个条件,比如输出以"root"或者以"daemon"开头的行: [root@svr5 ~]# grep '^root|^daemon'