Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cp file with a filter



Paul Hoffman wrote in news:20100114225814.GB24626@xxxxxxxxxxxx:

>> 
>> I want to copy a file to various subdirectories while changing a value
>> in the file on the fly
>> 
>> eg 
>> cat init.php | sed s/flag=2/flag=3/ > dir3/init.php

> 
> typeset -a flags
> flags=( 3 4 )
> for f in $flags; do
>     sed "s/flag=2/flag=$f/" init.php > dir$f/init.php
> done
> 
> Paul.
> 
thanks ; which in turn can be written

for i in {3,4}; sed s/flag=2/flag=$i/ init.php > dir$i/init.php


BTW apparently I was guilty of a UUOC
-- 
zzapper
http://zzapper.co.uk/ Technical Tips



Messages sorted by: Reverse Date, Date, Thread, Author