in reply to String Search/Replace
or in-place:perl -ple "@f=split; for(@f[1..4]){ $_=0 if $_>1000 } $_=qq{@f}" infil +e >outfile
Update:perl -i.bak -ple "@f=split; for(@f[1..4]){ $_=0 if $_>1000 } $_=qq{@f} +" file
Better yet, -a saves us the trouble of splitting:
or in-place:perl -lape "for(@F[1..4]){ $_=0 if $_>1000 } $_=qq{@F}" infile >outfil +e
perl -i.bak -lape "for(@F[1..4]){ $_=0 if $_>1000 } $_=qq{@F}" file
perlrun documents -i, -l, -a, -p and -e.
The command can be written in fewer strokes, but I left it readable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: String Search/Replace
by crep (Novice) on Aug 31, 2005 at 14:40 UTC | |
by ikegami (Patriarch) on Aug 31, 2005 at 14:41 UTC | |
by crep (Novice) on Aug 31, 2005 at 14:47 UTC |