Forum Moderators: bakedjake

Message Too Old, No Replies

how to type \r\n under bash

quick question

         

Xuefer

3:27 am on Mar 17, 2003 (gmt 0)

10+ Year Member



i wanna type control chars
\r not the \ and r itself
thx

bird

11:43 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can type in control chars if you type a ^V (ctrl-V) first. So in you case, the following will print an empty line:

$> echo '^V^R'

[/code]
[code]$>

(You won't actually see the ^V on screen anymore after typing the ^R)

Xuefer

2:02 am on Mar 18, 2003 (gmt 0)

10+ Year Member



got it
^V^J^V^M
right? :)

littleman

6:54 am on Mar 18, 2003 (gmt 0)



Gotta ask...why do you need to do this?

bird

12:20 pm on Mar 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



got it
^V^J^V^M

Actually, if you're trying to emulate DOS line endings, you'll probably want to reverse that. At least with my terminal settings, ^J ~= \n, and ^M ~= \r.
Other than that, you seem to be on the right track.

Xuefer

3:54 pm on Mar 18, 2003 (gmt 0)

10+ Year Member



thx bird

grep -n '^V^M^V^J' *.txt
scan for dos text :)

u have better way to do it?

bird

5:41 pm on Mar 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at the file command:

$> file some.txt
some.txt: ASCII text, with CRLF line terminators

It won't scan through the full text, so it may miss files where the line endings are mixed, but it's usually quite reliable for uniform files.

Xuefer

2:11 am on Mar 19, 2003 (gmt 0)

10+ Year Member



nice :)
but
[Administrator@my abc]$ file a.php
a.php: PHP script text

:(