From: solaristar on
So i have a file with a line

foo_bar_baz (some amount of whitespace) 100 (a number)

I basically want to have a search regex that searches foo_bar_baz(and
then to the end of the line regardless of what text)

and replace it with foo_bar_baz \t (tab) 101 (some dif number

---

my command is as such but isnt working

perl -i -pe 's/minutes_between_backups$/minutes_between_backups
\t1020/' /etc/myconffile*.conf

I thought $ matched to the end of the line?

From: solaristar on
On Jan 22, 10:26 am, solaristar <global...(a)hotmail.com> wrote:
> So i have a file with a line
>
> foo_bar_baz (some amount of whitespace) 100 (a number)
>
> I basically want to have a search regex that searches foo_bar_baz(and
> then to the end of the line regardless of what text)
>
> and replace it with foo_bar_baz \t (tab) 101 (some dif number
>
> ---
>
> my command is as such but isnt working
>
> perl -i -pe 's/minutes_between_backups$/minutes_between_backups
> \t1020/' /etc/myconffile*.conf
>
> I thought $ matched to the end of the line?

figured it out

perl -i -pe 's/minutes_between_backups.*/minutes_between_backups\t
\t1020/' /etc/myconf*.conf

thanks to

http://www.comp.leeds.ac.uk/Perl/matching.html
From: J�rgen Exner on
solaristar <globalsec(a)hotmail.com> wrote:
>So i have a file with a line
>
>foo_bar_baz (some amount of whitespace) 100 (a number)
>
>I basically want to have a search regex that searches foo_bar_baz(and
>then to the end of the line regardless of what text)
>
>and replace it with foo_bar_baz \t (tab) 101 (some dif number
>
>my command is as such but isnt working
>
>perl -i -pe 's/minutes_between_backups$/minutes_between_backups
>\t1020/' /etc/myconffile*.conf

/minutes_between_backups/ will never match 'foo_bar_buz'.

>I thought $ matched to the end of the line?

It matches the end of the line itself. If you want to match whatever
text between the current position and the end of the line then simply
use '.*'.

jue
From: solaristar on
On Jan 22, 12:11 pm, Jürgen Exner <jurge...(a)hotmail.com> wrote:
> solaristar <global...(a)hotmail.com> wrote:
> >So i have a file with a line
>
> >foo_bar_baz (some amount of whitespace) 100 (a number)
>
> >I basically want to have a search regex that searches foo_bar_baz(and
> >then to the end of the line regardless of what text)
>
> >and replace it with foo_bar_baz \t (tab) 101 (some dif number
>
> >my command is as such but isnt working
>
> >perl -i -pe 's/minutes_between_backups$/minutes_between_backups
> >\t1020/' /etc/myconffile*.conf
>
> /minutes_between_backups/ will never match 'foo_bar_buz'.
>
> >I thought $ matched to the end of the line?
>
> It matches the end of the line itself. If you want to match whatever
> text between the current position and the end of the line then simply
> use '.*'.
>
> jue

yup thanks i figured it out a bit after i posted hehe, i was using the
foo_bar_baz as an example of the text, not as the literal text :)
thanks for the reply though

From: Tad McClellan on
solaristar <globalsec(a)hotmail.com> wrote:
> On Jan 22, 10:26 am, solaristar <global...(a)hotmail.com> wrote:

>> I thought $ matched to the end of the line?
>
> figured it out

> thanks to
>
> http://www.comp.leeds.ac.uk/Perl/matching.html


The very first place to look for Perl help are the docs that
come with perl.

You needed to know about a regex metacharacter, and the "Metacharacters"
section in

perldoc perlre

says:

$ Match the end of the line (or before newline at the end)


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"