Finding a word at specific location in a string

Hi All ,

   I have different strings \(SQL queries infact\) of different lengths such as:
       1. "SELECT XYZ  FROM ABC WHERE ABC.DEF='123' "
       2. "DELETE FROM ABC WHERE ABC.DEF='567'"
       3. "SELECT  * FROM ABC"
    I need to find out the word coming after the word "FROM" in a shell script. For this I am       able to find the location of word "FROM". How can I find out the word at a location = location of word "FROM" \+ 1 ?  

Is there any better alternative for achieving purpose other than finding out locations of words?

TIA

sed 's/.*FROM \([^ ][^ ]*\).*/\1/' myFile

---------- Post updated at 08:49 AM ---------- Previous update was at 08:49 AM ----------

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums