You should have noticed that earlier when our one-liners did `cat
test.txt`. Anyway, assuming FILE is a constant filename pattern. Here
is a ruby one-liner. (ruby -ne 'puts
$_.gsub(/FILE./){"#{File.readlink($_.strip)}"}' test.txt > tmp ; mv
tmp test.txt). Yes the temporary file is necessary if we want it
short.

What exactly are you doing which forces you to do ugly hacks like
this. Some of us may want to take a stab at it.

Ed

On Nov 17, 2007 10:07 AM, Michael Tinsay <[EMAIL PROTECTED]> wrote:
>
> My apologies.  I have not made my original mail clearer.  I forgot to
> mention that the text file contains other data, like:
>
>
> <data>
> ...
> FILE0
> <more data>
> ...
> FILE1
> <even more data>
> ...
> FILE2
> <a whole lot more data>
>
>
> I just need to get these 3 markers/fields replaced before it gets processed
> by another program.
>
>
>
>
>
> ----- Original Message ----
> From: Eduardo Tongson <[EMAIL PROTECTED]>
> To: Philippine Linux Users' Group (PLUG) Technical Discussion List
> <[email protected]>
>
> Sent: Friday, November 16, 2007 7:03:15 PM
> Subject: Re: [plug] scripting question
>
> Use Lawrence's solution. My one-liner did not take slashes into account.
>
> On Nov 16, 2007 5:50 PM, Michael Tinsay <[EMAIL PROTECTED]> wrote:
> >
> > How do I escape the /'s?  readlink will return /foo/bar and I need to pass
> > it to sed as \/foo\/bar, or else sed will fail and return nothing.
> >
> >
> > --- mike t.
> >
> >
> > ----- Original Message ----
> > From: Eduardo Tongson <[EMAIL PROTECTED]>
> > To: Philippine Linux Users' Group (PLUG) Technical Discussion List
> > <[email protected]>
> > Sent: Friday, November 16, 2007 5:25:08 PM
> > Subject: Re: [plug] scripting question
> >
> > You need to look at the text file first.
> >
> > for i in `cat test.txt`; do sed -i s/$i/`readlink $i`/ test.txt ; done
> >
> >
> > _________________________________________________
> > Philippine Linux Users' Group (PLUG) Mailing List
> > [email protected] (#PLUG @ irc.free.net.ph)
> > Read the Guidelines: http://linux.org.ph/lists
> > Searchable Archives: http://archives.free.net.ph
> >
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> [email protected] (#PLUG @ irc.free.net.ph)
> Read the Guidelines: http://linux.org.ph/lists
> Searchable Archives: http://archives.free.net.ph
>
>
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> [email protected] (#PLUG @ irc.free.net.ph)
> Read the Guidelines: http://linux.org.ph/lists
> Searchable Archives: http://archives.free.net.ph
>
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Reply via email to