I just discovered that the inplace-edit value can now include an asterisk to mean "old file". This means you can now do cool tricks like put your "old" versions of the file into a subdirectory with the original name, not a modified name! Here's a one-liner that puts all the old files into a directory named for the unix epoch timestamp (a 10-digit integer increasing by one per second).
perl -pe 'BEGIN { mkdir $^T; $^I = "$^T/*" } s/foo/bar/g' file1 file2 +file3 ...
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Put your inplace-edit backup files into a subdir
by merlyn (Sage) on Apr 21, 2003 at 06:08 UTC | |
by Aristotle (Chancellor) on Apr 21, 2003 at 12:05 UTC |
Back to
Cool Uses for Perl