in reply to Replace current line in while loop
Update: For example, you could do exactly what you specify in your post with the one liner:
perl -pi -e 's/^((?:[^:]*:){4})/${1}UNDEF:/ if /^test:/' file.txt
However, if this script is intended to do more than just a simple search-and-replace, you'll likely be better off writing a proper script where you explicitly output a new file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replace current line in while loop
by walkingthecow (Friar) on May 13, 2009 at 18:17 UTC | |
by tilly (Archbishop) on May 13, 2009 at 18:23 UTC | |
by Marshall (Canon) on May 13, 2009 at 18:36 UTC | |
by kennethk (Abbot) on May 13, 2009 at 18:21 UTC |