Passing shell variables to awk and sed
By default awk and sed do not expand shell or system variables and do not pass their own variables back to the shell. To use shell variables awk and sed statements must be included in double-quotes. Here are a few examples:
1) You have a file (words.txt) containing a list of words and their replacements as shown below.
blue red yellow green stormy blue dark clearYou also have a text file (text.txt) where you need to replace the words from the list above with the corresponding alternatives.
blue flowers were growing on a yellow lawn under a dark stormy skyHere’s a shell script to do it:
#!/bin/ksh cat words.txt | while read LINE do O=$(echo "$LINE" | awk '{print $1}') R=$(echo "$LINE" | awk '{print $2}') cat text.txt | sed "s/$O/$R/g" > tmp.txt mv tmp.txt text.txt doneThe resulting text.txt file would read:
red flowers were growing on a green lawn under a clear blue sky
What are some real-world applications that involve a systems of linear equations? How can the graphing display calculator assist in determining the solutions of the system?
can you gues be very brief ?