grep

Error: “grep: Argument list too long” [duplicate]

随声附和 提交于 2020-01-22 07:36:24
问题 This question already has answers here : How can I grep while avoiding 'Too many arguments' [duplicate] (5 answers) Closed 4 years ago . I am trying to run the following command, but gets argument too long error. Can you help?. HOST# grep -rl 'pattern' /home/*/public_html/* -bash: /bin/grep: Argument list too long Is there a way to override this error and grep the pattern matching files I want in all users public_html directory. There are around 500+ users in the same server. 回答1: Use find

【Linux技术】ubuntu常用命令

自作多情 提交于 2020-01-22 07:26:47
查看软件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

LAMP架构

让人想犯罪 __ 提交于 2020-01-22 01:38:51
LAMP架构介绍 Linux+ Apache(httpd)+ mysql + php 操作系统+外网服务软件 + 存储软件 + 脚本语言(由C开发) PHP网站 三个角色可以装在一台机器,也可以分开,但是httpd要和php在一起(php是以模块的形式和apache结合在一起的,apache通过php和mysql打交道,) 动态请求:用户通过账号和密码登录apache,apache通过php去mysql里比对数据,对上后apache会返回给用户登录状态 静态请求:用户通过apache登录,apache直接去linux某个目录中去拿静态的文件或图片。不与mysql打交道Apache和PHP是一个整体,因为PHP是以一个模块的形式和Apache结合在一起,但是Apache不能直接和MySQL去连接,只能通过PHP这个模块去MySQL中提取数据,拿到数据后,PHP把这个结果交给Apache,Apache再交给用户。 PHP和MySQL交互数据的操作、行为,称为 动态请求。 MySQL_MariaDB介绍 mysql是一个关系型数据库。由mysql ab公司开发。在2008年被sun公司收购。sun公司(java)于2009年被oracle(数据库)公司收购。mysql走上了商业路线。官网:www.mysql.com 在版本5.6开始变化比较大。5.7性能上有很大提升。

如何过滤 adb logcat 输出

梦想的初衷 提交于 2020-01-21 20:41:06
简介 : 本文介绍如何在 shell 命令行 中过滤 adb logcat 输出的几个小技巧。 开发当中经常看到别人的 log 如洪水般瞬间刷满了屏幕,对自己有用的信息都被淹没了,影响心情也影响效率。下面是几个我所知道的过滤方法。 1. 只显示需要的输出,白名单 最方便的当然是通过管道使用 grep 过滤了,这样可以使用 grep 强大的正则表达式匹配。简单的匹配一行当中的某个字符串,例如 MyApp: adb logcat | grep MyApp adb logcat | grep -i myapp #忽略大小写。 adb logcat | grep --color=auto -i myapp #设置匹配字符串颜色。更多设置请查看 grep 帮助。 进阶一点可以使用 grep 的正则表达式匹配。例如上一个例子会匹配一行中任意位置的 MyApp,可以设置为仅匹配 tag。默认的 log 输出如下,如果修改过输出格式相应的表达式也要修改。 I/CacheService( 665): Preparing DiskCache for all thumbnails. 可以看出 tag 是一行开头的第三个字符开始,根据这点写出表达式: adb logcat | grep "^..MyApp" 根据这个格式也可以设置只显示某个优先级的 log,再匹配行首第一个字符即可。例如仅显示 Error

web 防攻击shell脚本

倾然丶 夕夏残阳落幕 提交于 2020-01-21 20:29:10
统计nginx日志,当单个ip在10秒钟内访问 /account/sendPhoneCode次数超过5次,就禁用这个ip,正常用户不可能有么大的访问量 #!/bin/bash #write: lijing QQ 858080796 #date: 20160528 v2.0 #description:拦截非法IP #定义变量 RETVAL=0 Date=$(date '+%Y-%m-%d') Time=$(date '+%Y:%H:%M' -d '-1 minute') MON=$(date|awk -F" " '{print $2}') TODAY=$(date|awk -F" " '{print $3}') Log="/data/logs/nginx/access.log " LINE="70000" #关键字 Key01="sendPhoneCode" Status=/tmp/statuS_deny_ip /sbin/service iptables status > $Status #定义函数 #禁止时间函数 secure_deny_time(){ Time01=$(date "+%H:%M:%S" -d " -10 second") Time02=$(date "+%H:%M:%S" -d " -9 second") Time03=$(date "+%H:%M:%S" -d

Linux系统防CC攻击自动拉黑IP增强版Shell脚本 《Linux系统防CC攻击自动拉黑IP增强版Shell脚本》来自张戈博客

本小妞迷上赌 提交于 2020-01-21 20:26:41
前天没事写了一个防CC攻击的Shell脚本,没想到这么快就要用上了,原因是因为360网站卫士的缓存黑名单突然无法过滤后台,导致WordPress无法登录!虽然,可以通过修改本地hosts文件来解决这个问题,但是还是想暂时取消CDN加速和防护来测试下服务器的性能优化及安全防护。 前天写的Shell脚本是加入到crontab计划任务执行的,每5分钟执行一次,今天实际测试了下,可还是可以用的,但是感觉5分钟时间有点过长,无法做到严密防护。于是稍微改进了下代码,现在简单的分享下! 一、Shell代码 Shell #!/bin/bash #Author:ZhangGe #Desc:Auto Deny Black_IP Script. #Date:2014-11-05 #取得参数$1为并发阈值,若留空则默认允许单IP最大50并发(实际测试发现,2M带宽,十来个并发服务器就已经无法访问了!) if [[ -z $1 ]];then num=50 else num=$1 fi #巧妙的进入到脚本工作目录 cd $(cd $(dirname $BASH_SOURCE) && pwd) #请求检查、判断及拉黑主功能函数 function check(){ iplist=`netstat -an |grep ^tcp.*:80|egrep -v 'LISTEN|127.0.0.1'|awk -F"[ ]

Can I use grep to extract a single column of a CSV file?

这一生的挚爱 提交于 2020-01-21 17:25:11
问题 I'm trying to solve o problem I have to do as soon as possible. I have a csv file, fields separated by ;. I'm asked to make a shell command using grep to list only the third column, using regex. I can't use cut. It is an exercise. My file is like this: 1;Evan;Bell;39;Obigod Manor;Ekjipih;TN;25008 2;Wayne;Watkins;22;Lanme Place;Cotoiwi;NC;86578 3;Danny;Vega;25;Fofci Center;Momahbih;MS;21027 4;Larry;Robinson;23;Bammek Boulevard;Gaizatoh;NE;27517 5;Myrtie;Black;20;Savon Square;Gokubpat;PA;92219

Effective grep of log file

前提是你 提交于 2020-01-21 16:49:35
问题 I have a log file with a lot of lines on this format: 10.87.113.12 - - [2019-12-09T11:41:07.197Z] "DELETE /page/sub1.php?id=alice HTTP/1.1" 401 275 "-" "alice/7.61.1" 10.87.113.12 - - [2019-12-09T11:41:07.197Z] "DELETE /page/sub1.php?id=alice HTTP/1.1" 401 275 "-" "alice/7.61.1" 10.87.113.12 - - [2019-12-09T11:43:51.008Z] "POST /page/sub2.php?id=alice&jw_token=07e876afdc2245b53214fff0d4763730 HTTP/1.1" 200 275 "-" "alice/7.61.1" My objective is simple: I want to output Alice's jw_token, and

Effective grep of log file

北城余情 提交于 2020-01-21 16:49:25
问题 I have a log file with a lot of lines on this format: 10.87.113.12 - - [2019-12-09T11:41:07.197Z] "DELETE /page/sub1.php?id=alice HTTP/1.1" 401 275 "-" "alice/7.61.1" 10.87.113.12 - - [2019-12-09T11:41:07.197Z] "DELETE /page/sub1.php?id=alice HTTP/1.1" 401 275 "-" "alice/7.61.1" 10.87.113.12 - - [2019-12-09T11:43:51.008Z] "POST /page/sub2.php?id=alice&jw_token=07e876afdc2245b53214fff0d4763730 HTTP/1.1" 200 275 "-" "alice/7.61.1" My objective is simple: I want to output Alice's jw_token, and

grep command with a lookahead pattern does not select anything

大兔子大兔子 提交于 2020-01-21 14:39:47
问题 I was trying to use the following grep command: grep '(.*)(?=(png|html|jpg|js|css)(?:\s*))(png|html|jpg|js|css.*\s)' file File contains the following: http://manage.bostonglobe.com/GiftTheGlobe/LandingPage.html https://manage.bostonglobe.com/cs/mc/login.aspx?p1=BGFooter https://www.bostonglobe.com/bgcs /newsletters?p1=BGFooter_Newsletters https://bostonglobe.custhelp.com/app/home?p1=BGFooter https://bostonglobe.custhelp.com/app/answers/list?p1=BGFooter /tools/help/stafflist?p1=BGFooter https: