sed application?

トップ ページ
添付ファイル:
Eメールのメッセージ
+ (text/plain)
このメッセージを削除
このメッセージに返信
著者: David A. Sinck
日付:  
題目: sed application?

\_ SMTP quoth Mike Starke on 2/13/2003 13:03 as having spake thusly:
\_
\_ I have a case where I need to change the value
\_ of a variable in a number of Perl scripts.
\_
\_ How would I take the results of a grep command
\_ and apply a change to it? For instance, if I
\_ issue the command:
\_
\_ 'grep -r smtp_addr *'
\_
\_ and get a bunch of results like:
\_
\_ 1stfile: $smtp_adrr = "old_value";
\_ 2ndfile: $smtp_adrr = "old_value";
\_ 3rdfile: $smtp_adrr = "old_value";
\_ 4thfile: $smtp_adrr = "old_value";

perl -pi.bak -e 's/(smtp_addr = ").*?"/$1new_value"/g' files*

David