Skip to content

awk

awk '{print $2,$4}' employees.txt 
awk '$3=="Engineering" {print $2,$4}'  employees.txt 
awk -F, 'NR>1 {print $1, $2+$3+$4}' /root/awklab/scores.csv > /root/awklab/totals.txt
awk '$4 > 75000 {print $2, $4}' /root/awklab/employees.txt > /root/awklab/high-salary.txt

CUT

cut -d' ' -f1 access.log | sort | uniq -c | sort -rn > ip-report.txt
cut -d',' -f2,3 /root/log 


sort -rn
uniq -c

Grep

i
n
c
r
-E "Err|WARN"
grep -E "ERROR|WARN" server.log > warnings-errors.txt 

Json

show human readable json

jq '.' users.json

find a key

jq '.users[0].name' users.json

 jq '.[] | select(.active= "true"  and  .role=="developer") .name ' users.json  > active-devs.txt
jq '[.[] | select(.active == true)] | length' /root/jqlab/users.json > /root/jqlab/count.txt