1 |
On 02/03/14 18:52, Mike Gilbert wrote: |
2 |
>On Mon, Feb 3, 2014 at 6:14 PM, Joseph <syscon780@×××××.com> wrote: |
3 |
>> I have a text file. How do I search and replace "carriage return"? |
4 |
>> |
5 |
> |
6 |
>Do you mean carriage return (decimal 13) or line feed (decimal 10)? |
7 |
> |
8 |
>The former is pretty simple: |
9 |
> |
10 |
>sed -e 's:\r: :g' foo.txt |
11 |
|
12 |
OK here is the text output (last few lines) of the command: cat 15.txt | sed 's/\r$//' | od -c |
13 |
|
14 |
... |
15 |
0017460 o w t h e m a j o r g r o |
16 |
0017500 u p i n g s o f \n d i n o s a |
17 |
0017520 u r s . \n L e t ' s m o v e |
18 |
0017540 o n f r o m d i n o s a u r |
19 |
0017560 s k e l e t o n s t o \n o u |
20 |
0017600 t w a r d a p p e a r a n c e |
21 |
0017620 s . \n |
22 |
|
23 |
the actual text: |
24 |
ow the major groupings of |
25 |
dinosaurs. |
26 |
Let's move on from dinosaur skeletons to |
27 |
outward appearances. |
28 |
|
29 |
so it seems to me the carriage return is represented by: " \n" |
30 |
|
31 |
I've tried |
32 |
sed -e 's:\n: :g' 15.txt |
33 |
|
34 |
makes no difference. How to replace the "\n" with space. |
35 |
|
36 |
-- |
37 |
Joseph |