0

How to remove characters from a string like this

"i have string in a variable say string="auto.deploy.active = yes", i want to take out everything after "=" and store that extracted string in another variable using a shell script"

Cyrus
  • 69,405
  • 13
  • 65
  • 117
James Taylor
  • 127
  • 2
  • 10

2 Answers2

0

You can use awk

command is:

$ var1=`echo "auto.deploy.active = yes" | awk -F"=" '{print $1}'` ; echo $var1
auto.deploy.active 

$ var2=`echo "auto.deploy.active = yes" | awk -F"=" '{print $2}'` ; echo $var2
yes
Cyrus
  • 69,405
  • 13
  • 65
  • 117
Akhil Jalagam
  • 585
  • 6
  • 18
0

With bash and Parameter Expansion:

string="auto.deploy.active = yes"
value="${string#*= }"
Cyrus
  • 69,405
  • 13
  • 65
  • 117