public inbox for speakup@linux-speakup.org
 help / color / mirror / Atom feed
From: "Laura Eaves" <leaves1@carolina.rr.com>
To: "Speakup is a screen review system for Linux." <speakup@braille.uwo.ca>
Subject: Re: can't invoke sed properly...
Date: Mon, 2 May 2005 16:58:59 -0400	[thread overview]
Message-ID: <05b801c54f59$c31a6de0$6401a8c0@geekspeak> (raw)
In-Reply-To: <20050502205023.GA10916@taylor.homelinux.net>

Be careful putting the output into the same file as the input.
Note that I/O redirection takes place before the programs start running, so 
cat will open myfile and the shell will redirect the output to the input of 
sed, and before sed or cat ever start running, the shell will clobber the 
output file if it exists to make way for the output of sed.
Just use different names and later move the file back to the original if you 
want it updated.
Oh and you don't use the -e option -- I don't remember what version of sed I 
was using when I ran that.
But the -e option is useful if you have several patterns to apply to each 
input line.  sed will read the -e options left to right and treat each 
pattern as being on one line.  Of course you could always just use a quoted 
pattern that ran over multiple lines, but it is cleaner to use -e.

Finally, be careful using sed or any other pattern matching command, that 
you use single quotes instead of double quotes on the command line, as using 
double quotes will result in some undesired translation.  For example:

sed "1,$d"

will actually translate to

sed "1,xyz"

where xyz is the value of the environment variable d.
Lots of little gotchas in pattern matching.
Have fun!
--le

----- Original Message ----- 
From: "Lorenzo Taylor" <lorenzo@taylor.homelinux.net>
To: "Speakup is a screen review system for Linux." <speakup@braille.uwo.ca>
Sent: Monday, May 02, 2005 4:50 PM
Subject: Re: can't invoke sed properly...


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Someone tell me if there is an easier way, but this worked for me:

cat my-file | sed "s/red/blue/g" > my-file

This line replaced red with blue every time it appeared in the file.

I am using GNU sed version 4.1.4 here.  Your mileage may vary.

Lorenzo
- -- 
"We decided that we should evaluate the Microsoft offerings first. Once we
realised what a powerful set of tools they were, it became self-evident this 
was
the right way to go down."

Microsoft: the right way to go down
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCdpKPG9IpekrhBfIRAg8oAJ0WeiXYLHbneHy2fzhSDq79r/23YACglvjU
j3rSTXu9XzKF+eUximAMCB0=
=sm17
-----END PGP SIGNATURE-----

_______________________________________________
Speakup mailing list
Speakup@braille.uwo.ca
http://speech.braille.uwo.ca/mailman/listinfo/speakup 



  reply	other threads:[~ UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
 Ned
 ` Laura Eaves
 ` Lorenzo Taylor
   ` Laura Eaves [this message]
     ` Lorenzo Taylor
     ` Charles Hallenbeck
       ` Laura Eaves
         ` Charles Hallenbeck

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='05b801c54f59$c31a6de0$6401a8c0@geekspeak' \
    --to=leaves1@carolina.rr.com \
    --cc=speakup@braille.uwo.ca \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).