为了使我的脚本更具可读性,我正在尝试拆分我的长 grep 模式。那可能吗?
示例,在 bash 脚本中,而不是这条长线
smartctl -a /dev/sda | grep -Ei "Spin_Retry_Count|Calibration_Retry_Count|Reallocated_Event_Count|Offline_Uncorrectable|Reallocated_Sector_Ct|Current_Pending_Sector|CRC_Error_Count|Multi_Zone_Error_Rate|Temperature|CRC_Error_Count|Runtime_Bad_Block|Erase_Fail_Count|Program_Fail_C|End-to-End_Error" | awk '{print $2" "$10}')
我想分成类似的东西,使事情更具可读性
smartctl -a /dev/sda | grep -Ei "Spin_Retry_Count|"\
"Calibration_Retry_Count|"\
"Reallocated_Event_Count|"\
"Offline_Uncorrectable|"\
"Reallocated_Sector_Ct|"\
"Current_Pending_Sector|"\
"CRC_Error_Count|"\
"Multi_Zone_Error_Rate|"\
"Temperature|"\
"CRC_Error_Count|"\
"Runtime_Bad_Block|"\
"Erase_Fail_Count|"\
"Program_Fail_C|"\
"End-to-End_Error" | awk '{print $2" "$10}')