all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: w_a_x_man <w_a_x_man@yahoo.com>
To: help-gnu-emacs@gnu.org
Subject: Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?
Date: Sat, 22 Aug 2009 11:24:56 -0700 (PDT)	[thread overview]
Message-ID: <1bc82397-1e91-4055-879a-c178534e1c17__15002.750643953$1250966591$gmane$org@z24g2000yqb.googlegroups.com> (raw)
In-Reply-To: 1380cb14-6462-4585-b2d1-c59c99ff9b56@b15g2000yqd.googlegroups.com

On Aug 22, 1:11 pm, bolega <gnuist...@gmail.com> wrote:
> sed/awk/perl:
>
> How to replace all spaces each with an underscore that occur before a
> specific string ?
>
> I really prefer a sed one liner.
>
> Example
> Input :  This is my book. It is too  thick to read. The author gets
> little royalty but the publisher makes a lot.
> Output: This_is_my_book._It_is_too__thick_to read. The author gets
> little royalty but the publisher makes a lot.
>
> We replaced all the spaces with underscores before the first occurence
> of the string "to ".
>
> Thanks
> Gnuist

awk 'BEGIN{FS=OFS="to "}{gsub(/ /,"_",$1);print}' myfile


       reply	other threads:[~2009-08-22 18:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1380cb14-6462-4585-b2d1-c59c99ff9b56@b15g2000yqd.googlegroups.com>
2009-08-22 18:24 ` w_a_x_man [this message]
2009-08-22 23:02 ` sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ? Ed Morton
2009-08-22 18:11 bolega

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1bc82397-1e91-4055-879a-c178534e1c17__15002.750643953$1250966591$gmane$org@z24g2000yqb.googlegroups.com' \
    --to=w_a_x_man@yahoo.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.