我已经完成了研究,但无法找到解决问题的方法。我正在尝试提取字符串中的所有有效单词(以字母开头)并将它们与下划线(“_”)连接起来。我正在寻找 awk、sed 或 grep 等的解决方案。
就像是:
echo "The string under consideration" | (awk/grep/sed) (pattern match)
示例 1
输入:
1.2.3::L2 Traffic-house seen during ABCD from 2.2.4/5.2.3a to 1.2.3.X11
期望的输出:
L2_Traffic_house_seen_during_ABCD_from
示例 2
输入:
XYZ-2-VRECYY_FAIL: Verify failed - Client 0x880016, Reason: Object exi
期望的输出:
XYZ_VRECYY_FAIL_Verify_failed_Client_Reason_Object_exi
示例 3
输入:
ABCMGR-2-SERVICE_CRASHED: Service "abcmgr" (PID 7582) during UPGRADE
期望的输出:
ABCMGR_SERVICE_CRASHED_Service_abcmgr_PID_during_UPGRADE