我的文件的内容:file.conf 是
sm key mappings
sm_key_7_value_0="/www/cgi-bin/scripts/app_web_mood_control.sh Global masteron;echo hello"
sm_key_7_value_1="/www/cgi-bin/scripts/app_web_mood_control.sh Global masteroff"
sm_key_8_value_0="/www/cgi-bin/scripts/app_web_mood_control.sh Global green"
sm_key_8_value_1="/www/cgi-bin/scripts/app_web_mood_control.sh Global away"
sm_key_9_value_0="/www/cgi-bin/scripts/app_usr_core_sendPulse.sh CR_D601 C1_OPN"
sm_key_9_value_1="/www/cgi-bin/scripts/app_usr_core_sendPulse.sh CR_D601 C1_CLS"
sm_key_A_value_0="/www/cgi-bin/scripts/app_oasis_irControl.sh IR_D03 AC_ON_"
sm_key_A_value_1="/www/cgi-bin/scripts/app_oasis_irControl.sh IR_D03 AC_OFF"
sm_key_B_value_0="/www/cgi-bin/scripts/app_usr_core_sendInstruction.sh CR_D601 OP_01N"
sm_key_B_value_1="/www/cgi-bin/scripts/app_usr_core_sendInstruction.sh CR_D601 OP_01F"
sm_key_C_value_0="/www/cgi-bin/scripts/app_usr_core_sendInstruction.sh CR_D601 OP_02N"
sm_key_C_value_1="echo 123 && $(sleep 5) && $(echo hello)"
我用过grep
grep "/www/cgi-bin/scripts/app_web_mood_control.sh" file.conf
grep 的输出是
sm_key_7_value_0="/www/cgi-bin/scripts/app_web_mood_control.sh Global masteron;echo hello"
sm_key_7_value_1="/www/cgi-bin/scripts/app_web_mood_control.sh Global masteroff"
sm_key_8_value_0="/www/cgi-bin/scripts/app_web_mood_control.sh Global green"
sm_key_8_value_1="/www/cgi-bin/scripts/app_web_mood_control.sh Global away"
在 grep 的这个 o/p 中,我需要访问 global masteron
Global masteroff
Global green
Global away
它并将其放入一个变量中。目的是我想访问 control.sh 之后的任何内容并将其存储在变量中如何实现这一点。