China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 04:28
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How can the sed command determine the line number of an overlong line? View 914 Replies 4
Original Poster Posted 2010-06-21 17:28 ·  中国 广东 深圳 电信
初级用户
Credits 21
Posts 21
Joined 2010-06-19 17:50
16-year member
UID 169155
Gender Male
Status Offline
Right now I have a text file, and inside it there is one very long line. The contents of the line are character, tab, character, tab.....

After opening it with Notepad, I found that this line is already displayed as 3 lines (word wrap is not enabled).
(When opened with excle I found it is 1 line, and it has already extended to column IG, with probably more than 270 tabs)

So would sed treat this as one line or 3 lines?

Also, how does the sed command recognize tabs (what is the wildcard for tabs)?
Floor 2 Posted 2010-06-21 17:55 ·  中国 江苏 扬州 电信
初级用户
Credits 90
Posts 43
Joined 2007-10-31 11:00
18-year member
UID 101268
Gender Male
Status Offline
Use a regular expression to identify lines; the line-ending symbol is $. The several lines you see are just a display issue. You can try opening it with ultraedit and have a look.

Tabs are generally represented with \t.
Floor 3 Posted 2010-06-21 18:19 ·  中国 广东 深圳 电信
初级用户
Credits 21
Posts 21
Joined 2010-06-19 17:50
16-year member
UID 169155
Gender Male
Status Offline
After checking the hex, I found that this line really has only one 0D 0A
But why can't sed "line number"d filename delete it?
The line number is the one shown in the status bar.
Floor 4 Posted 2010-06-21 19:02 ·  中国 江苏 扬州 电信
初级用户
Credits 90
Posts 43
Joined 2007-10-31 11:00
18-year member
UID 101268
Gender Male
Status Offline
Could it be that the sed command was written incorrectly?

Under unix it is generally written like this:
sed 'm,nd' means deleting the content from line m through line n.
Floor 5 Posted 2010-06-21 21:05 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
1 line
\t
Forum Jump: