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
  • 84,225
  • 14
  • 89
  • 153
James Taylor
  • 355
  • 1
  • 4
  • 13

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
  • 84,225
  • 14
  • 89
  • 153
Akhil
  • 912
  • 12
  • 23
0

With bash and Parameter Expansion:

string="auto.deploy.active = yes"
value="${string#*= }"
Cyrus
  • 84,225
  • 14
  • 89
  • 153