Article View: comp.unix.shell
Article #4102sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?
From: bolega
Date: Sat, 22 Aug 2009 18:11
Date: Sat, 22 Aug 2009 18:11
18 lines
1835 bytes
1835 bytes
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
Technical Details
Message-ID:
<1380cb14-6462-4585-b2d1-c59c99ff9b56@b15g2000yqd.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!b15g2000yqd.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: bd748d9281,9ccd2e7066d84876,start X-Google-Attributes: gidbd748d9281,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!b15g2000yqd.googlegroups.com!not-for-mail From: bolega <gnuist006@gmail.com> Newsgroups: comp.unix.shell,gnu.emacs.help,comp.lang.python,comp.lang.lisp,comp.lang.scheme Subject: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ? Date: Sat, 22 Aug 2009 11:11:32 -0700 (PDT) Organization: http://groups.google.com Lines: 21 Message-ID: <1380cb14-6462-4585-b2d1-c59c99ff9b56@b15g2000yqd.googlegroups.com> NNTP-Posting-Host: 75.32.191.209 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1250964692 17749 127.0.0.1 (22 Aug 2009 18:11:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 22 Aug 2009 18:11:32 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b15g2000yqd.googlegroups.com; posting-host=75.32.191.209; posting-account=REkl4woAAABFXaU7nL79XtGpnmNCQ415 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe)