I want to use regex in bash at line of variable assignmente.g.oldip=14\.130\.31\.172oldip_a=14.130.31.172 << How to use regex to del all '\'? and assign to oldip_aDo you have any idea?
How to assign value of variable with regex (bash)?
bash;string
To remove the \, use bash parameter substitution.// means replace all ... (a single / would mean replace only the first)//\\ means replace all \ (backslash) chars/} means replace with nothing (There is nothing bewtween / and the closing } ip=14\.130\.31\.172echo ${ip//\\/}Output  14.130.31.172Or, if there are many occurrences \. to do, in a file with many such IP addresses, you can assign each modified value to an array item.   ip=($(printf '172.31.130.1414\.130\.31\.17233\.135\.220\.0' | sed 's/\\//g'))for ((i=0;i<${#ip[@]};i++));do  echo ${ip[i]}doneoutput172.31.130.1414.130.31.17233.135.220.0?! .. I just noticed that your second data item is a reversal of the first.. Is that what you want as your output? (probably not, but it got me wondering)..