EXPERT RESPONSE
I like AWK the best for this kind of thing. You can execute simple type AWK programs right at the Unix prompt. Here is an example of something that might work for you:
awk '/string/ {"yourtextstring" print $2 }' < test_input_file > output_file
This would first search for all records in the file that have the /string/. Then it would would extract all lines with a character sequence matching that pattern, parse each line into fields separated by blanks, put "yourteststring" in the first field, and output the second field in the file. Play around with this a bit. The general Unix awk man page is a good start. Here's a nice little link worth looking at: http://www.engr.utk.edu/ecc/unix/man/awk.php
If you want to set-up flow control using if-then-else logic, here is your format at a high level.
if (condition)
{ commands1 }
[ else
{ commands2 } ]
Though there is much you can do at the beginner's level, you will learn awk best by trying many different things with examples. If you want a good book to help you, not only with awk, but sed, another strong text manipulation tool, check out this link, from O'Reilly. They have really good Unix books, and this is one of many: http://www.oreilly.com/catalog/sed2/
Good luck!
|