A few examples of shell skills

A few examples of shell skills

 

  • Generally, our program will have requirements: if the data changes, update to the database. At the same time, we will record the relevant log, and we can also find out the total number of records that have changed from the log. 
    grep -o 'CLF6_F:.*$' CLF6_13_00_14_00_input.log |  awk 'BEGIN {last="zzzzzxxx";} { if(last!=$0) {total++; last=$0;} } END { print "changed records is",total;}'
     
  • We sometimes need to customize data replacement, such as finding a row containing keyword A, replace keyword B with C in this row
    sed -i  '/GRANT EXECUTE ON PROCEDURE .*.f_.*$/{s/PROCEDURE/FUNCTION/g}' C.sql
     
  • Sometimes, we can access B on host A, but not C, but we can access C on host B. In order to directly access C on host A, an SSH channel can be established directly.
    ssh -fNg -L 3307:C:3306 prj@B
    
    mysql -h 127.0.0.1 -P 3307 -uuser -ppwd
     

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326872528&siteId=291194637