grep

强制重启tomcat的sh

ぃ、小莉子 提交于 2020-01-23 09:46:52
我写的狗屎 ps aux |grep tomcat_9090_uba |grep -v grep &>/dev/null if [ $? -ne 0 ];then sh /home/tomcat_9090_uba/bin/startup.sh &>/dev/null echo "tomcat9090 start" else ps aux |grep tomcat_9090_uba --color=auto |grep -v grep |awk '{print $2}' |xargs kill -9 && echo "tomcat9090 online" sh /tmp/duidui.sh fi 这。。。唉 ps aux |grep -v grep | grep tomcat_9090_uba &>/dev/null # 如果pid不存在,$?为非零,即直接重启 if [ $? -ne 0 ];then echo "tomcat9090 is not running" sh /home/tomcat_9090_uba/bin/startup.sh &>/dev/null pid=`ps aux |grep -v grep |grep tomcat_9090_uba | awk '{print $2}'` echo "start tomcat9090 successfully, the

Shell Script to get exception from logs for last one hour

独自空忆成欢 提交于 2020-01-23 07:38:21
问题 I am developing script which will grep logs of last one hour and check any exception and send email for solaris platform. I did following steps grep -n -h date +'%Y-%m-%d %H:%M' test.logs above command gives me line number and then i do following tail +6183313 test.log | grep 'exception' sample logs 2014-02-17 10:15:02,625 | WARN | m://mEndpoint | oSccMod | 262 - com.sm.sp-client - 0.0.0.R2D03-SNAPSHOT | 1201 or 101 is returned as exception code from SP, but it is ignored 2014-02-17 10:15:02

Fast string search in a very large file

徘徊边缘 提交于 2020-01-23 04:16:20
问题 What is the fastest method for searching lines in a file containing a string. I have a file containing strings to search. This small file (smallF) contains about 50,000 lines and looks like: stringToSearch1 stringToSearch2 stringToSearch3 I have to search all of these strings in a larger file (about 100 million lines). If any line in this larger file contains the search string the line is printed. The best method I have come up with so far is grep -F -f smallF largeF But this is not very fast

How do I store a command in a variable and use it in a pipeline? [duplicate]

拜拜、爱过 提交于 2020-01-23 03:27:25
问题 This question already has answers here : Why does shell ignore quotes in arguments passed to it through variables? [duplicate] (3 answers) Closed 3 years ago . If i use this command in pipeline, it's working very well; pipeline ... | grep -P '^[^\s]*\s3\s' But if I want to set grep into variable like: var="grep -P '^[^\s]*\s3\s'" And if I put variable in pipeline; pipeline ... | $var nothing happens, like there isn't any matches. Any help what am I doing wrong? 回答1: The robust way to store a

appium之安卓7.0环境搭建

左心房为你撑大大i 提交于 2020-01-23 01:28:47
appium 在安卓7.0的手机上运行上报错---------Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.] 解决方法: 进入Appium安装目录,找到目录下的adb.js(D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js) adb.js 中1035 行( 出错原因:this.shell("ps '" + name + "'", function (err, stdout) {对应执行的指令是ps 'uiautomator', Android7不支持这个指令格式,所以执行结果是bad pid 'uiautomator' ) this.shell("ps '" + name + "'", function (err, stdout) { if (err) return cb(err); 替换成 this.shell_grep("ps", name, function (err, stdout) { if (err) { logger.debug("No matching processes

自学笔记

我们两清 提交于 2020-01-23 00:01:08
ps -ef | grep mysql ps -ef 的意思显示系统执行进程 -e 显示所有终端机下执行的进程 -f 指的是显示UID,PPIP,C与STIME栏位 grep 是搜索过滤 ps -ef | grep mysql的含义就是显示系统执行进程,从显示的全部进程信息中搜索包含mysql字符串的信息,并显示出来 来源: CSDN 作者: qq_40607462 链接: https://blog.csdn.net/qq_40607462/article/details/103968676

Simultaneous pipe to grep and redirect to stdout

随声附和 提交于 2020-01-22 20:50:10
问题 In Linux bash, I am trying to run a command and grep for an argument: command | grep However, I need to redirect the result of the commad to the stdout and simultaneously pipe it to grep (I need to see both the grep result and the command result in stdout). I googled a bit and tried some variations, such as: command | tee /dev/tty | grep But, no luck. I don't want to use sth like command command | grep as it is ugly :) Thanks, 回答1: Try command | tee >(grep whatever) Note that there's no space

sys_check

橙三吉。 提交于 2020-01-22 17:31:24
#!/bin/bash # auth:kaliarch # func:sys info check # version:v1.0 # sys:centos6.x/7.x [ $(id -u) -gt 0 ] && echo "请用root用户执行此脚本!" && exit 1 sysversion=$(rpm -q centos-release|cut -d- -f3) line="-------------------------------------------------" [ -d logs ] || mkdir logs sys_check_file="/var/log/$(ip a show dev ens192|grep -w inet|awk '{print $2}'|awk -F '/' '{print $1}')-`date +%Y%m%d`.txt" # 获取系统cpu信息 function get_cpu_info() { Physical_CPUs=$(grep "physical id" /proc/cpuinfo| sort | uniq | wc -l) Virt_CPUs=$(grep "processor" /proc/cpuinfo | wc -l) CPU_Kernels=$(grep "cores" /proc/cpuinfo|uniq|

How to grep rows that have value less than 0.2 in a specific column?

谁都会走 提交于 2020-01-22 12:15:52
问题 ID RT EZ Z0 Z1 Z2 RHO PHE 1889 UN NA 1.0000 0.0000 0.0000 0.8765 -1 1890 UN NA 1.0000 0.0000 0.0000 0.4567 -1 1891 UN NA 1.0000 0.0000 0.0000 0.0012 -1 1892 UN NA 1.0000 0.0000 0.0000 0.1011 -1 I would like to grep all the IDs that have column 'RHO' with value less than 0.2, and the other columns are included for the selected rows. 回答1: Use awk directly by saying awk '$field < value' : $ awk '$7<0.2' file 1891 UN NA 1.0000 0.0000 0.0000 0.0012 -1 1892 UN NA 1.0000 0.0000 0.0000 0.1011 -1 As

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

风格不统一 提交于 2020-01-22 11:06:14
几个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 Update 5)