in reply to Regular expression and rename file help
Otherwise, try this code:#!/bin/sh cat file | sed ``/VALUE/s//$1/'' > file.`date "+%s"`
use strict; use warnings; my $user_input = shift || die "I need input"; my $file = "file"; open FH, $file or die "can't open $file for reading $!"; my @arr = <FH>; close FH; foreach(@arr){ s/VALUE/$user_input/g; } open FH, ">$file" or die "can't open $file for writing $!"; print FH @arr; close FH; rename $file, $file.time;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression and rename file help
by kitty (Novice) on Feb 03, 2006 at 10:22 UTC | |
by blazar (Canon) on Feb 03, 2006 at 13:08 UTC |