I'm a little bit confused about the use of awk/sed in a script. I've skimmed through the guides to both and it seems to me like they only operate on files/stdin/stdout, is that right? What I am trying to do is write a simple expression to extract a substring from a bash variable and re-assign the variable to that substring. Specifically the variable consists of an executable's name (+ it's path) and it's inputs. So something like this:
exec_target="/usr/bin/gcc -c my_program my_program.c"
# And here I want to write an expression to extract "gcc" and reassign it to exec_target
I know there are multiple ways of doing this and I could do it in the blink of an eye if this script I wrote was in Perl, but what's a fast, simple way of doing it in the Bash world and what tool (awk/sed) is best suited for this type of task? Thanks