Re: insert carriage return before string

From: Page, Jennifer (Jennifer.Page@RBCDAIN.COM)
Date: Thu May 22 2003 - 16:43:24 EDT


Could use very simple script:

#!/usr/bin/ksh

while read a b c
do
        if [[ $b = "right" ]]
        then
                echo "$a \n$b $c"
        else
                echo $a $b $c
        fi
done < [input text file]

-----Original Message-----
From: T. Lists [mailto:tracylists@YAHOO.COM]
Sent: Thursday, May 22, 2003 2:07 PM
To: aix-l@Princeton.EDU
Subject: insert carriage return before string

Hi all.

Maybe I'm being a doofus, but I need some help. How
can I scriptically (ok, I made that word up) insert a
carriage return before a particular string in a file?
I don't want whole blank line before the line that
contains the string, but I want a new line character
inserted before the string itself. For example, if my
input file looks like:

      Here is line 1
      of my file
      and right here is line 4.

I want a new line character inserted before the word
"right". So, I want it to look like:

      Here is line 1
      of my file
      and
      right here is line 4.

I can't quite figure out how to do this. I get the
feeling I'm missing something pretty simple here.

Thanks for your help.

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com

RBC Dain Rauscher does not accept buy, sell or cancel orders by e-mail, or any instructions by e-mail that would require your signature. Information contained in this communication is not considered an official record of your account and does not supersede normal trade confirmations or statements. Any information provided has been prepared from sources believed to be reliable but is not guaranteed, does not represent all available data necessary for making investment decisions and is for informational purposes only.

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you receive this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Information received by or sent from this system is subject to review by supervisory personnel, is retained and may be produced to regulatory authorities or others with a legal right to the information.



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:51 EDT