Why doesn't sed 's/$/^M/' work as expected?

Why doesn't sed 's/$/^M/' work as expected?

Post by Clive Clomsbarro » Wed, 06 May 1998 04:00:00



Please explain this shell log:

$ echo a | sed 's/a/\^M/' | od -t x1
0000000 0a 0a
0000002

The "^M" was a real control-M input via emacs-like ^Q^M.

Why isn't that first "0a" a "0d" as expected.
I can't believe "sed" has a bug.

 
 
 

Why doesn't sed 's/$/^M/' work as expected?

Post by Joi Ell » Thu, 07 May 1998 04:00:00


: Please explain this shell log:
:
: $ echo a | sed 's/a/\^M/' | od -t x1
: 0000000 0a 0a
: 0000002
:
: The "^M" was a real control-M input via emacs-like ^Q^M.

Try using \r instead of ^M...?

:
: Why isn't that first "0a" a "0d" as expected.
: I can't believe "sed" has a bug.
:
:

--

Joi Ellis


 
 
 

Why doesn't sed 's/$/^M/' work as expected?

Post by Robert Nicho » Thu, 07 May 1998 04:00:00




:Please explain this shell log:
:
:$ echo a | sed 's/a/\^M/' | od -t x1
:0000000 0a 0a
:0000002
:
:The "^M" was a real control-M input via emacs-like ^Q^M.
:
:Why isn't that first "0a" a "0d" as expected.

Works fine for me, both with and without the backslash.  Perhaps your
shell is doing something funny with the ^M.  Try replacing "sed" with
"/bin/echo" and see if the argument is getting through intact.

--

 
 
 

1. why doesn't 'tar' work?

I've noticed in my RedHat 7.2 install that 'tar' doesn't seem to work.  For
any file  xxxx.tar.gz  when I issue the command

    tar --gunzip --extract xxxx.tar.gz

(or with 'z' replacing '-gunzip', 'x' replacing '-extract'), absolutely
nothing happens.  When I finally stop it with a Ctrl-Z, the prompt comes
back, and then I can kill the stopped tar process.  This behavior is in-
dependent of my being root or user, and occurs both from a cmd line shell
and from MC's cmd line.

Further, if I first unzip the *.gz file using gunzip, then use 'tar':

    tar --extract xxxx.tar

exactly the same thing happens.

OTOH, from MC I can simply press Enter on the *.gz file and see all its
content, and also copy any selection of files to whereever I want.  So ap-
parently 'tar' or its equivalent works for MC, but not for me the way I was
trying to use it.  Anyone have any suggestions as to what I'm doing wrong?

Thx.

- Dushan Mitrovich

2. lp messages when printer offline

3. Why: perl -e <<'EOF' doesn't work (bash)

4. File-restore

5. Why doesn't 'write' work??

6. drivers & updates for Sol 7 x86

7. Why doesn't echo "text" 'command' "more text" work?

8. How to blank EEPROM of RTL8139

9. Why doesn't 'cut' utility work intuitively?

10. Why 'man' doesn't work?

11. Why doesn't echo "text" 'command' "more text" work?

12. ping -g 'gateway-IP' 'host-IP' DOESN'T work!

13. Why doesn't this test script with timeout work as I expect?