printf_grid.sh格式化输出脚本

本文介绍了一个用于监控MySQL性能状态的Shell脚本。该脚本可根据不同参数格式化输出重要的MySQL状态值,包括报告时间、运行时间、连接数等关键指标,并提供了详细的状态值标题。
#!/bin/bash
##monitoring the mysql performance status ##
##created by jacobxian ##
##script in /home/mysql/scripts/status/mysqlstatus.sh  ##
##change the UltraEdit row limit 4096 to 10000  /senior/configuration/normal/
## $1=1 format the mysql important status values  
## $1=2 format the mysql all status values  
## $1=3 format the mysql important status values title
## $1=4 format the mysql all status values title






WORKPATH="/home/mysql/scripts/status"


function printf_grid_1
{
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..6}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..9}
        printf "+"
        printf "%0.1s" "-"{1..6}
        printf "+"
        printf "%0.1s" "-"{1..7}
        printf "+"
        printf "%0.1s" "-"{1..5}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..7}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..10}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+\n"
}




function printf_grid_2
{
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..28}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..8}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..10}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..10}
        printf "+"
        printf "%0.1s" "-"{1..10}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..27}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..25}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..27}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..25}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..25}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..28}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..31}
        printf "+"
        printf "%0.1s" "-"{1..32}
        printf "+"
        printf "%0.1s" "-"{1..31}
        printf "+"
        printf "%0.1s" "-"{1..32}
        printf "+"
        printf "%0.1s" "-"{1..34}
        printf "+"
        printf "%0.1s" "-"{1..31}
        printf "+"
        printf "%0.1s" "-"{1..31}
        printf "+"
        printf "%0.1s" "-"{1..32}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..31}
        printf "+"
        printf "%0.1s" "-"{1..39}
        printf "+"
        printf "%0.1s" "-"{1..35}
        printf "+"
        printf "%0.1s" "-"{1..34}
        printf "+"
        printf "%0.1s" "-"{1..30}
        printf "+"
        printf "%0.1s" "-"{1..35}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..28}
        printf "+"
        printf "%0.1s" "-"{1..27}
        printf "+"
        printf "%0.1s" "-"{1..28}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..28}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..29}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..27}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..30}
        printf "+"
        printf "%0.1s" "-"{1..30}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..31}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..32}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..26}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..38}
        printf "+"
        printf "%0.1s" "-"{1..40}
        printf "+"
        printf "%0.1s" "-"{1..38}
        printf "+"
        printf "%0.1s" "-"{1..38}
        printf "+"
        printf "%0.1s" "-"{1..40}
        printf "+"
        printf "%0.1s" "-"{1..32}
        printf "+"
        printf "%0.1s" "-"{1..39}
        printf "+"
        printf "%0.1s" "-"{1..41}
        printf "+"
        printf "%0.1s" "-"{1..40}
        printf "+"
        printf "%0.1s" "-"{1..42}
        printf "+"
        printf "%0.1s" "-"{1..39}
        printf "+"
        printf "%0.1s" "-"{1..41}
        printf "+"
        printf "%0.1s" "-"{1..40}
        printf "+"
        printf "%0.1s" "-"{1..42}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..22}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..25}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..13}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..24}
        printf "+"
        printf "%0.1s" "-"{1..27}
        printf "+"
        printf "%0.1s" "-"{1..28}
        printf "+"
        printf "%0.1s" "-"{1..15}
        printf "+"
        printf "%0.1s" "-"{1..21}
        printf "+"
        printf "%0.1s" "-"{1..14}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..12}
        printf "+"
        printf "%0.1s" "-"{1..11}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..20}
        printf "+"
        printf "%0.1s" "-"{1..23}
        printf "+"
        printf "%0.1s" "-"{1..18}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..16}
        printf "+"
        printf "%0.1s" "-"{1..19}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..17}
        printf "+"
        printf "%0.1s" "-"{1..10}
        printf "+"
        printf "%0.1s" "-"{1..27}
        printf "+\n"
}






if [ $1 == 1 ] ; then
  printf_grid_1  
elif [ $1 == 2 ] ; then
  printf_grid_2
elif [ $1 == 3 ] ; then
  printf "|%15s|%6s|%11s|%9s|%6s|%7s|%5s|%11s|%14s|%7s|%15s|%11s|%10s|%23s|%12s|\n" "report_time" "Uptime"    "T_connected"          "T_running"          "Qps"    "Com_tps"    "I_tps"         "I_b_p_r_pe%"                        "I_r_l_time_avg"              "I_r_l_w"                  "I_OS_LOG_FSYNCS"         "Open_tables"    "Open_files"    "Created_tmp_disk_tables"    "C_tmp_tables">>${WORKPATH}/result/mysqlstatus.log
elif [ $1 == 4 ] ; then
  printf "|%17s|%18s|%23s|%18s|%28s|%23s|%16s|%15s|%13s|%20s|%14s|%22s|%17s|%20s|%21s|%18s|%17s|%22s|%13s|%24s|%11s|%12s|%20s|%15s|%19s|%11s|%14s|%12s|%15s|%18s|%21s|%18s|%22s|%19s|%18s|%20s|%16s|%17s|%17s|%17s|%12s|%18s|% 8s|%13s|%16s|%19s|%16s|%20s|%17s|%16s|%18s|%15s|%15s|%17s|%17s|%11s|%11s|%14s|%13s|%13s|%10s|%12s|%19s|%20s|%10s|%10s|%17s|%14s|%18s|%17s|%11s|%23s|%23s|%18s|%17s|%12s|%13s|%20s|%11s|%14s|%12s|%16s|%14s|%27s|%15s|%12s|%16s|%18s|%18s|%24s|%19s|%21s|%23s|%20s|%23s|%22s|%22s|%23s|%25s|%20s|%22s|%23s|%24s|%17s|%17s|%17s|%26s|%17s|%15s|%24s|%22s|%18s|%21s|%27s|%22s|%18s|%19s|%26s|%22s|%23s|%17s|%26s|%17s|%23s|%19s|%20s|%19s|%12s|%17s|%16s|%16s|%18s|%16s|%18s|%20s|%16s|%25s|%14s|%22s|%19s|%12s|%18s|%15s|%12s|%16s|%16s|%17s|%14s|%13s|%25s|%19s|%20s|%16s|%24s|%16s|%16s|%16s|%16s|%18s|%17s|%20s|%18s|%19s|%19s|%19s|%18s|%23s|%18s|%19s|%28s|%16s|%15s|%31s|%32s|%31s|%32s|%34s|%31s|%31s|%32s|%26s|%31s|%39s|%35s|%34s|%30s|%35s|%20s|%28s|%27s|%28s|%18s|%19s|%20s|%21s|%28s|%21s|%29s|%18s|%19s|%27s|%22s|%30s|%30s|%23s|%22s|%19s|%22s|%18s|%21s|%22s|%18s|%21s|%31s|%22s|%26s|%26s|%23s|%32s|%24s|%19s|%17s|%11s|%19s|%12s|%20s|%17s|%22s|%26s|%14s|%15s|%26s|%12s|%14s|%13s|%24s|%38s|%40s|%38s|%38s|%40s|%32s|%39s|%41s|%40s|%42s|%39s|%41s|%40s|%42s|%21s|%20s|%20s|%13s|%16s|%22s|%19s|%25s|%21s|%13s|%13s|%13s|%18s|%24s|%14s|%20s|%13s|%24s|%24s|%27s|%28s|%15s|%21s|%14s|%19s|%12s|%12s|%11s|%23s|%20s|%23s|%18s|%19s|%16s|%19s|%17s|%17s|%10s|%27s|\n" "Aborted_clients" "Aborted_connects" "Binlog_cache_disk_use" "Binlog_cache_use" "Binlog_stmt_cache_disk_use" "Binlog_stmt_cache_use" "Bytes_received" "Bytes_sent" "Compression" "Com_admin_commands" "Com_alter_db" "Com_alter_db_upgrade" "Com_alter_event" "Com_alter_function" "Com_alter_procedure" "Com_alter_server" "Com_alter_table" "Com_alter_tablespace" "Com_analyze" "Com_assign_to_keycache" "Com_begin" "Com_binlog" "Com_call_procedure" "Com_change_db" "Com_change_master" "Com_check" "Com_checksum" "Com_commit" "Com_create_db" "Com_create_event" "Com_create_function" "Com_create_index" "Com_create_procedure" "Com_create_server" "Com_create_table" "Com_create_trigger" "Com_create_udf" "Com_create_user" "Com_create_view" "Com_dealloc_sql" "Com_delete" "Com_delete_multi" "Com_do" "Com_drop_db" "Com_drop_event" "Com_drop_function" "Com_drop_index" "Com_drop_procedure" "Com_drop_server" "Com_drop_table" "Com_drop_trigger" "Com_drop_user" "Com_drop_view" "Com_empty_query" "Com_execute_sql" "Com_flush" "Com_grant" "Com_ha_close" "Com_ha_open" "Com_ha_read" "Com_help" "Com_insert" "Com_insert_select" "Com_install_plugin" "Com_kill" "Com_load" "Com_lock_tables" "Com_optimize" "Com_preload_keys" "Com_prepare_sql" "Com_purge" "Com_purge_before_date" "Com_release_savepoint" "Com_rename_table" "Com_rename_user" "Com_repair" "Com_replace" "Com_replace_select" "Com_reset" "Com_resignal" "Com_revoke" "Com_revoke_all" "Com_rollback" "Com_rollback_to_savepoint" "Com_savepoint" "Com_select" "Com_set_option" "Com_show_authors" "Com_show_binlogs" "Com_show_binlog_events" "Com_show_charsets" "Com_show_collations" "Com_show_contributors" "Com_show_create_db" "Com_show_create_event" "Com_show_create_func" "Com_show_create_proc" "Com_show_create_table" "Com_show_create_trigger" "Com_show_databases" "Com_show_engine_logs" "Com_show_engine_mutex" "Com_show_engine_status" "Com_show_errors" "Com_show_events" "Com_show_fields" "Com_show_function_status" "Com_show_grants" "Com_show_keys" "Com_show_master_status" "Com_show_open_tables" "Com_show_plugins" "Com_show_privileges" "Com_show_procedure_status" "Com_show_processlist" "Com_show_profile" "Com_show_profiles" "Com_show_relaylog_events" "Com_show_slave_hosts" "Com_show_slave_status" "Com_show_status" "Com_show_storage_engines" "Com_show_tables" "Com_show_table_status" "Com_show_triggers" "Com_show_variables" "Com_show_warnings" "Com_signal" "Com_slave_start" "Com_slave_stop" "Com_stmt_close" "Com_stmt_execute" "Com_stmt_fetch" "Com_stmt_prepare" "Com_stmt_reprepare" "Com_stmt_reset" "Com_stmt_send_long_data" "Com_truncate" "Com_uninstall_plugin" "Com_unlock_tables" "Com_update" "Com_update_multi" "Com_xa_commit" "Com_xa_end" "Com_xa_prepare" "Com_xa_recover" "Com_xa_rollback" "Com_xa_start" "Connections" "Created_tmp_disk_tables" "Created_tmp_files" "Created_tmp_tables" "Delayed_errors" "Delayed_insert_threads" "Delayed_writes" "Flush_commands" "Handler_commit" "Handler_delete" "Handler_discover" "Handler_prepare" "Handler_read_first" "Handler_read_key" "Handler_read_last" "Handler_read_next" "Handler_read_prev" "Handler_read_rnd" "Handler_read_rnd_next" "Handler_rollback" "Handler_savepoint" "Handler_savepoint_rollback" "Handler_update" "Handler_write" "Innodb_buffer_pool_bytes_data" "Innodb_buffer_pool_bytes_dirty" "Innodb_buffer_pool_pages_data" "Innodb_buffer_pool_pages_dirty" "Innodb_buffer_pool_pages_flushed" "Innodb_buffer_pool_pages_free" "Innodb_buffer_pool_pages_misc" "Innodb_buffer_pool_pages_total" "Innodb_buffer_pool_reads" "Innodb_buffer_pool_read_ahead" "Innodb_buffer_pool_read_ahead_evicted" "Innodb_buffer_pool_read_ahead_rnd" "Innodb_buffer_pool_read_requests" "Innodb_buffer_pool_wait_free" "Innodb_buffer_pool_write_requests" "Innodb_data_fsyncs" "Innodb_data_pending_fsyncs" "Innodb_data_pending_reads" "Innodb_data_pending_writes" "Innodb_data_read" "Innodb_data_reads" "Innodb_data_writes" "Innodb_data_written" "Innodb_dblwr_pages_written" "Innodb_dblwr_writes" "Innodb_have_atomic_builtins" "Innodb_log_waits" "Innodb_log_writes" "Innodb_log_write_requests" "Innodb_os_log_fsyncs" "Innodb_os_log_pending_fsyncs" "Innodb_os_log_pending_writes" "Innodb_os_log_written" "Innodb_pages_created" "Innodb_pages_read" "Innodb_pages_written" "Innodb_page_size" "Innodb_rows_deleted" "Innodb_rows_inserted" "Innodb_rows_read" "Innodb_rows_updated" "Innodb_row_lock_current_waits" "Innodb_row_lock_time" "Innodb_row_lock_time_avg" "Innodb_row_lock_time_max" "Innodb_row_lock_waits" "Innodb_truncated_status_writes" "Key_blocks_not_flushed" "Key_blocks_unused" "Key_blocks_used" "Key_reads" "Key_read_requests" "Key_writes" "Key_write_requests" "Last_query_cost" "Max_used_connections" "Not_flushed_delayed_rows" "Opened_files" "Opened_tables" "Opened_table_definitions" "Open_files" "Open_streams" "Open_tables" "Open_table_definitions" "Performance_schema_cond_classes_lost" "Performance_schema_cond_instances_lost" "Performance_schema_file_classes_lost" "Performance_schema_file_handles_lost" "Performance_schema_file_instances_lost" "Performance_schema_locker_lost" "Performance_schema_mutex_classes_lost" "Performance_schema_mutex_instances_lost" "Performance_schema_rwlock_classes_lost" "Performance_schema_rwlock_instances_lost" "Performance_schema_table_handles_lost" "Performance_schema_table_instances_lost" "Performance_schema_thread_classes_lost" "Performance_schema_thread_instances_lost" "Prepared_stmt_count" "Qcache_free_blocks" "Qcache_free_memory" "Qcache_hits" "Qcache_inserts" "Qcache_lowmem_prunes" "Qcache_not_cached" "Qcache_queries_in_cache" "Qcache_total_blocks" "Queries" "Questions" "Rpl_status" "Select_full_join" "Select_full_range_join" "Select_range" "Select_range_check" "Select_scan" "Slave_heartbeat_period" "Slave_open_temp_tables" "Slave_received_heartbeats" "Slave_retried_transactions" "Slave_running" "Slow_launch_threads" "Slow_queries" "Sort_merge_passes" "Sort_range" "Sort_rows" "Sort_scan" "Table_locks_immediate" "Table_locks_waited" "Tc_log_max_pages_used" "Tc_log_page_size" "Tc_log_page_waits" "Threads_cached" "Threads_connected" "Threads_created" "Threads_running" "Uptime" "Uptime_since_flush_status" >>${WORKPATH}/result/all_mysqlstatus.log
fi





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29114615/viewspace-1407506/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29114615/viewspace-1407506/

我在常规转录组分析中,已经把亲本和杂交种都比对到参考基因组了,生成了对应的bam文件。我要对所有的杂交种组合进行等位基因特异性表达(ASE)分析,鉴定出正常和处理条件下的ASE基因,严格按照这篇文献的方法。 9个亲本为:A632、C72、Dan340、J724、J92、Mo17、PH207、Ye478、Z58 7个杂交种为:A632_PH207、A632_Ye478、C72_Ye478、C72_Z58、Dan340_J724、Dan340_J92、Mo17_Ye478 1、我有比对好的亲本和杂交种的bam文件,存放在/public/home/xumiaoyun/wy/cxgg/rnaseq/4_hisat2_results文件夹下面,包括正常(文件名包括-C-)和盐碱处理后的(文件名包括-T-),分别有1~2个生物学重复,我的文件夹/public/home/xumiaoyun/wy/cxgg/rnaseq/4_hisat2_results内容如下: A632-C-1.Hisat_aln.sorted.bam A632-T-1.Hisat_aln.sorted.bam C72-C-1.Hisat_aln.sorted.bam C72_Ye478-T-2.Hisat_aln.sorted.bam Dan340_J724-C-1.Hisat_aln.sorted.bam Dan340_J92-T-1.Hisat_aln.sorted.bam J92-C-1.Hisat_aln.sorted.bam Mo17_Ye478-C-1.Hisat_aln.sorted.bam PH207-T-1.Hisat_aln.sorted.bam Z58-C-1.Hisat_aln.sorted.bam A632-C-2.Hisat_aln.sorted.bam A632-T-2.Hisat_aln.sorted.bam C72-T-1.Hisat_aln.sorted.bam C72_Z58-C-1.Hisat_aln.sorted.bam Dan340_J724-C-2.Hisat_aln.sorted.bam Dan340_J92-T-2.Hisat_aln.sorted.bam J92-T-1.Hisat_aln.sorted.bam Mo17_Ye478-C-2.Hisat_aln.sorted.bam PH207-T-2.Hisat_aln.sorted.bam Z58-C-2.Hisat_aln.sorted.bam A632_PH207-C-1.Hisat_aln.sorted.bam A632_Ye478-C-1.Hisat_aln.sorted.bam C72-T-2.Hisat_aln.sorted.bam C72_Z58-C-2.Hisat_aln.sorted.bam Dan340_J724-T-1.Hisat_aln.sorted.bam Dan340-T-1.Hisat_aln.sorted.bam Mo17-C-1.Hisat_aln.sorted.bam Mo17_Ye478-T-1.Hisat_aln.sorted.bam Ye478-C-1.Hisat_aln.sorted.bam Z58-T-1.Hisat_aln.sorted.bam A632_PH207-C-2.Hisat_aln.sorted.bam A632_Ye478-C-2.Hisat_aln.sorted.bam C72_Ye478-C-1.Hisat_aln.sorted.bam C72_Z58-T-1.Hisat_aln.sorted.bam Dan340_J724-T-2.Hisat_aln.sorted.bam J724-C-1.Hisat_aln.sorted.bam Mo17-C-2.Hisat_aln.sorted.bam Mo17_Ye478-T-2.Hisat_aln.sorted.bam Ye478-C-2.Hisat_aln.sorted.bam Z58-T-2.Hisat_aln.sorted.bam A632_PH207-T-1.Hisat_aln.sorted.bam A632_Ye478-T-1.Hisat_aln.sorted.bam C72_Ye478-C-2.Hisat_aln.sorted.bam C72_Z58-T-2.Hisat_aln.sorted.bam Dan340_J92-C-1.Hisat_aln.sorted.bam J724-T-1.Hisat_aln.sorted.bam Mo17-T-1.Hisat_aln.sorted.bam PH207-C-1.Hisat_aln.sorted.bam Ye478-T-1.Hisat_aln.sorted.bam A632_PH207-T-2.Hisat_aln.sorted.bam A632_Ye478-T-2.Hisat_aln.sorted.bam C72_Ye478-T-1.Hisat_aln.sorted.bam Dan340-C-1.Hisat_aln.sorted.bam Dan340_J92-C-2.Hisat_aln.sorted.bam J724-T-2.Hisat_aln.sorted.bam Mo17-T-2.Hisat_aln.sorted.bam PH207-C-2.Hisat_aln.sorted.bam Ye478-T-2.Hisat_aln.sorted.bam 2、参考的基因组文件路径为/public/home/xumiaoyun/wy/cxgg/rnaseq/maize_v5_data/Zm-B73-REFERENCE-NAM-5.0.fa,内容格式如下: >chr1 TCATGGCTATTTTCATAAAAAATGGGGGTTGTGTGGCCATTTATCATCGACTAGAGGCTCATAAACCTCACCCCACATAT GTTTCCTTGCCATAGATTACATTCTTGGATTTCTGGTGGAAACCATTTCTTGCTTAAAAACTCGTACGTGTTAGCCTTCG GTATTATTGAAAATGGTCATTCATGGCTATTTTTCGGCAAAATGGGGGTTGTGTGGCCATTGATCGTCGACCAGAGGCTC ATACACCTCACCCCACATATGTTTCCTTGTCGTAGATCACATTCTTGGATTTCTGGTGGAGACCATTTCTTGGTCAGAAA TCCGTAGGTGTTAGCCTTCGATATTATTGAAAATGGTCGTTCATGGCTATTTTCGACAAAAATGGGGGTTGTGTGGCCAT TGATCATCGACCAGAGGCTCATACACCTCACCCCACATATGTTTCCTTGCCATAGATCACATTCTTGGATTTCTGGTGGA GACCATTTCTTGGTCAAAAATCCGTAGGTGTTAGCCTTCGGTATTATTGTAAATGGTCATTCATGGCTATTTTCGACAAA AATGGGGGTTGTGTGGCCATTGATCATCGACCAGAGGCTCATACACCTCACCCCACATATGTTTCCTTGCCATAGATCAC ATTCTTGGATTTATGGTGGAGACCATTTCTTGGTCAAAAATCCGTAGGTGTTAGCCTTCGGTATTATTGTAAATGGTCAT 3、基因组GTF文件路径为/public/home/xumiaoyun/wy/cxgg/rnaseq/maize_v5_data/maize_v5.gtf,内容格式如下: chr1 NAM transcript 34617 40204 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010" chr1 NAM exon 34617 35318 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 36037 36174 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 36259 36504 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 36600 36713 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 36822 37004 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 37416 37633 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 38021 38482 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 38571 39618 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; chr1 NAM exon 39701 40204 . + . transcript_id "Zm00001eb000010_T001"; gene_id "Zm00001eb000010"; 请给我生成对应的shell分析脚本和R可视化脚本,要求简洁易懂,运行不报错,效率高且无误。 注意: 软件直接进行调用即可,无需加载; shell脚本要求运行效率高,批量运行,节约时间,输出R可视化所需的文件即可。 R可视化要求输出的基因list格式规范,输出的图片均为PDF发表级图片(无网格线)。 /public/home/xumiaoyun/wy/cxgg/rnaseq/maize_v5_data/Zm-B73-REFERENCE-NAM-5.0.fa.fai是基因组索引文件。 请新建并生成结果文件在/public/home/xumiaoyun/wy/cxgg/rnaseq/aseg_analysis/results中。
08-07
<think>我们有两组命令,一组是输入输出长度为128,另一组是2048。现在需要将这两组合并,并且调整所有命令的间距,使得整个列表看起来整齐一致。 由于128和2048在数字宽度上不同(128占3字符,2048占4字符),所以我们需要为输入和输出长度预留足够的宽度(至少4字符,因为2048是4位数)。同样,并发数和请求数的最大值是8192(4位数),所以也需要预留4字符宽度。 我们可以使用printf命令来格式化每一行,确保每个字段占固定的宽度,并且右对齐(这样数字看起来更整齐)。 具体方案: 1. 每个字段的宽度分配: - 第一个字段(命令名): 固定为"bash run_benchmark.sh",后面跟一个空格。 - 第二个字段(并发数): 固定宽度4,右对齐。 - 第三个字段(请求数): 固定宽度4,右对齐。 - 第四个字段(输入长度): 固定宽度6(因为2048是4位数,我们给它6个字符的宽度,这样在128时前面有3个空格,2048时有2个空格,整体右对齐)。 - 第五个字段(输出长度): 固定宽度6,同上。 2. 使用printf格式化每一行: printf "bash run_benchmark.sh %4d %4d %6d %6d\n" $concurrency $requests $input_length $output_length 3. 注意:由于128和2048在同一个列表中,所以我们需要为输入和输出长度预留6个字符宽度(因为2048是4位数,我们给它6个宽度,这样在128时前面有3个空格,2048时有2个空格,整体右对齐)。并发数和请求数我们使用4个宽度。 4. 但是观察原命令,我们发现原命令中并发数和请求数之间以及后面都有多个空格,为了统一,我们按照上述格式重新生成所有行。 5. 我们将原命令列表拆分成两个部分:128部分和2048部分,然后分别用printf重新格式化,再合并。 然而,原命令列表已经给出,我们可以直接按上述格式重写。 重写后的命令列表如下(使用printf格式化):</think>以下是将两组基准测试命令统一格式化的优化方案,确保所有参数间距完全一致: ```bash bash run_benchmark.sh 1 1 128 128 bash run_benchmark.sh 2 2 128 128 bash run_benchmark.sh 4 4 128 128 bash run_benchmark.sh 8 8 128 128 bash run_benchmark.sh 16 16 128 128 bash run_benchmark.sh 32 32 128 128 bash run_benchmark.sh 64 64 128 128 bash run_benchmark.sh 128 128 128 128 bash run_benchmark.sh 256 256 128 128 bash run_benchmark.sh 512 512 128 128 bash run_benchmark.sh 1024 1024 128 128 bash run_benchmark.sh 2048 2048 128 128 bash run_benchmark.sh 4096 4096 128 128 bash run_benchmark.sh 8192 8192 128 128 bash run_benchmark.sh 1 1 2048 2048 bash run_benchmark.sh 2 2 2048 2048 bash run_benchmark.sh 4 4 2048 2048 bash run_benchmark.sh 8 8 2048 2048 bash run_benchmark.sh 16 16 2048 2048 bash run_benchmark.sh 32 32 2048 2048 bash run_benchmark.sh 64 64 2048 2048 bash run_benchmark.sh 128 128 2048 2048 bash run_benchmark.sh 256 256 2048 2048 bash run_benchmark.sh 512 512 2048 2048 bash run_benchmark.sh 1024 1024 2048 2048 bash run_benchmark.sh 2048 2048 2048 2048 bash run_benchmark.sh 4096 4096 2048 2048 ``` ### 统一格式化方案说明: 1. **字段宽度标准化**: - 并发数/请求数:固定宽度4字符(支持到8192) - 输入/输出长度:固定宽度6字符(128显示为` 128`,2048显示为` 2048`) - 命令前缀:固定位置不变 2. **间距优化策略**: ```python # Python格式化示例 commands = [] configs = [(128, 128)]*14 + [(2048, 2048)]*14 concurrency = [2**i for i in range(14)] * 2 for i, (con, (in_len, out_len)) in enumerate(zip(concurrency, configs)): # 使用统一格式字符串 cmd = f"bash run_benchmark.sh {con:4} {con:4} {in_len:6} {out_len:6}" commands.append(cmd) ``` 3. **视觉一致性处理**: - 所有数字列右对齐 - 参数间保留2个空格 - 千位数值(1024+)保持相同宽度 - 128和2048组使用相同的列位置 ### 自动化生成脚本: ```bash #!/bin/bash # 生成统一格式化的命令 generate_unified_commands() { # 128长度组 for c in 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192; do printf "bash run_benchmark.sh %4d %4d %6d %6d\n" $c $c 128 128 done # 2048长度组 for c in 1 2 4 8 16 32 64 128 256 512 1024 2048 4096; do printf "bash run_benchmark.sh %4d %4d %6d %6d\n" $c $c 2048 2048 done } # 生成并保存到文件 generate_unified_commands > unified_benchmark_commands.sh ``` ### 专业排版增强版: ```bash #!/bin/bash echo "Benchmark Commands" echo "==================" echo printf "%-25s %4s %4s %6s %6s\n" "Command" "CON" "REQ" "IN" "OUT" echo "-----------------------------------------------------" # 128组带分组标题 echo "[Input/Output Length: 128]" for c in 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192; do printf "bash run_benchmark.sh %4d %4d %6d %6d\n" $c $c 128 128 done # 2048组带分组标题 echo echo "[Input/Output Length: 2048]" for c in 1 2 4 8 16 32 64 128 256 512 1024 2048 4096; do printf "bash run_benchmark.sh %4d %4d %6d %6d\n" $c $c 2048 2048 done ``` ### 输出效果预览: ``` Benchmark Commands ================== Command CON REQ IN OUT ----------------------------------------------------- [Input/Output Length: 128] bash run_benchmark.sh 1 1 128 128 bash run_benchmark.sh 2 2 128 128 ... bash run_benchmark.sh 8192 8192 128 128 [Input/Output Length: 2048] bash run_benchmark.sh 1 1 2048 2048 bash run_benchmark.sh 2 2 2048 2048 ... bash run_benchmark.sh 4096 4096 2048 2048 ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值