common utils:
- to lower case:
echo Happy | tr “[:upper:]” “[:lower:]”
file operations:
show file size with human readable format
1
ls -lash
List your top 10 favorite commands
1
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
get disk used percent
1
df -hP {{disk_path}} | awk '{print $5}' |tail -1|sed 's/%$//g'
sum total for column 4
1
awk -F"\t" '{print;x+=$4}END{print "Total " x}' 2018-07-06.csv
count file column number
1
head -1 targetfile | sed 's/[^,]//g'|wc -c
filter data rows
1
cat jmtdata_AllSites_2018-07-06.csv |awk '{if($1=="303790" && $9=="2018-07-06") print $1,$9}'|wc -l
send email
1
echo -e "All CSV files are generated successfully \n Date: $2 $(date "+%H:%M:%S") \n Thanks, \n Test"| mail -s "Success" test@gmail.com
sql insert
1
2echo -e "UPSERT INTO SAP_DATATELEMETRY VALUES('${rowKey}','${datatype}','0','${jobEndTIME}','0','${dataEntry}','$4');" > insert_jmt_telemetry.sql
/opt/cloudera/parcels/APACHE_PHOENIX/lib/phoenix/bin/psql.py sap-zookeeper1-gsb:2181 insert_jmt_telemetry.sql
Loop Func:
1 | !/usr/bin/env bash |