Home > database >  String control by variable at shell script
String control by variable at shell script

Time:08-19

I want to control string by variable at shell script.

input data

IDS_STR = 11 22 33 44 55 66 77
chk_id = 22

expected output (echo ${handled_ids_str})

22 33 44 55 66 77

I tried method

handled_ids_str=echo "${chk_id} ${IDS_STR}|cut -d '${chk_id}' -f2"
handled_ids_str=echo "${chk_id} ${IDS_STR}|awk -F'${chk_id}' '{print $2}'"
.....
ETC.

please your advice. Thanks

CodePudding user response:

I solved

af_awk=$(echo ${IDS_STR}|awk -F${chk_id} '{print $2}')
handled_ids_str=$(echo ${chk_id} ${af_awk})
  • Related