EDIT
So after about hour and half , I came up with this:
awk -F' ' '{ gsub(/\^/,"@ "); for (i=1;i<=NF;i++){ if($i ~ /\@/) $i = toupper($i);};gsub("@ ","");gsub("@",""); print } ' removecharsfile
Basic ideas:
- get rid of ^ and replace it with @ plus space
- Treat space as field delimiter; now we have fields to play with
- for loop to step through each field in each line, and check if there is @ character.
- if there is @ character, convert that field to upper. Why $i = toupper($i) ? Because otherwise it doesn't get stored anywhere
- after the loop is done, get rid of @+space, and any @ at the end of fields.
- print everything
Perhaps better approach to writing all this on one line is to put it in a file ( neatly organized bellow ), and run that with awk like so awk -f awkscript theinputfile
# awk script to capitalize
# whatever comes before caret(^)
{
gsub (/\^/, "@ ");
for (i = 1; i <= NF; i++)
{
if ($i ~ /\@/)
$i = toupper ($i);
};
gsub ("@ ", "");
gsub ("@", "");
print
}
And here it is in action:

ORIGINAL POST
I'll contribute my own code version with awk:
awk -F'^' '{print toupper($1)$2}' thefile
And of course you can redirect output with > output.txt
And here it is in action:

foo^bar^foo