Modify bash variables with sed
Posted
by
Alexander Cska
on Stack Overflow
See other posts from Stack Overflow
or by Alexander Cska
Published on 2014-06-12T08:35:38Z
Indexed on
2014/06/12
9:24 UTC
Read the original article
Hit count: 195
I am trying to modify a number of environmental variables containing predefined compiler flags. To do so, I tried using a bash loop that goes over all environmental variables listed with "env".
for i in $(env | grep ipo | awk 'BEGIN {FS="="} ; { print $1 } ' )
do echo $(sed -e "s/-ipo/ / ; s/-axAVX/ /" <<< $i)
done
This is not working since the loop variable $i contains just the name of the environmental variable stored as a character string. I tried searching a method to convert a string into a variable but things started becoming unnecessary complicated. The basic problem is how to properly supply the environmental variable itself to sed.
Any ideas how to properly modify my script are welcome.
Thanks, Alex
© Stack Overflow or respective owner