Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell scripting



Problem solved! Just found out we can use any other character for sed
instead of forward slashes, so using '@' was doing the job:

for i in `head $1`; do
sed -e s@'$i'@'#$i'@ $2 > newfile
done


On Sat, 26 May 2001, Sven Simon wrote:

> I have a file X which lists filenames in the dir tree such as /etc/hosts
> or whatever and I have a file Y including a subset of the names listed in
> file X.
>
> Now, what I'd like to do is comment out all those lines in file X which
> show names included in file Y. I've tried to use sed with no success:
> for i in `cat $1`; do
> sed -e s/"$i"/"#$i"/ $2
> done
>
> with $1 being file X and $2 being file Y
>
> I believe the problem is because of the forward slashes in the filenames
> Is there a way to make this work, could I use anything else than sed?
>
> SVEN
>
> -----------------------------------------------------------------------
> Next Technical Meeting:  Sat, May 12 13:30-
> Next Nomikai Meeting:    Fri, June (TBA) 19:30- Tengu Tokyo Eki Mae
> -----------------------------------------------------------------------
> more info: http://www.tlug.gr.jp           Sponsor: Global Online Japan
>
>


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links