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-06-22 00:08
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question: Organize the text (newcomers and veterans are all welcome to try) View 6,074 Replies 54
Floor 46 Posted 2008-07-15 15:05 ·  中国 湖北 武汉 联通
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
According to the idea of change, then sed can be improved like this
sed ":nt; $!{N; s/\n//; tnt}; s/。/&\n\n/g" myfile.txt
Floor 47 Posted 2008-07-15 15:29 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Originally posted by lxmxn at 2008-7-15 15:05:
According to the idea of change, then sed can be improved like this
sed ":nt; $!{N; s/\n//; tnt}; s/。/&\n\n/g" myfile.txt

It is possible, but if the file is too large, it won't work, right? Can the pattern space hold too much content?
致精致简!
Floor 48 Posted 2008-07-15 15:44 ·  中国 湖北 武汉 联通
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by 26933062 at 2008-7-15 15:29:

It is possible, but if the file is too large, it won't work, right? Can the pattern space hold too much content?

Hmm, if the file is large, it probably won't work.

Just tried it. Files under 10K are processed relatively quickly, but above 50K, it's relatively slow, and files over a megabyte are not suitable.
Floor 49 Posted 2008-07-16 08:20 ·  中国 山西 电信
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
Reply to floor 45

This is my execution result. Except for changing the test file path, nothing else has changed. The line "cd.>d\c.txt" is not necessary.


Batch files (Batch File, referred to as BAT files) are a kind of most commonly used executable files under DOS. It has flexible operability and can adapt to various complex computer operations. The so-called batch processing means automatically executing several specified DOS commands or programs in a specified order.
That is, it is to collect the originally executed commands one by one and execute them in batches, and the program file can be ported to other computers for operation, so it can greatly save the tediousness of repeatedly entering commands. At the same time, batch files also have some programming characteristics. It can flexibly control the execution of the program through extended parameters, so it is very practical in daily work. Batch. bat. cmd. Each has its own strengths and weaknesses.
Floor 50 Posted 2008-07-16 10:25 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Originally posted by qzwqzw at 2008-7-16 08:20:
Reply to post 45
This is my execution result
Except for changing the test file path
Nothing else has changed
The sentence "cd.>d\c.txt" is not necessary


Finally figured it out, it turns out that there can't be that slash after n..
change f:\111\d\a.txt /nf:\111\d\c.txt /from "nnn" /to " yyy " /in not "。"

Brother qzwqzw, can you have a slash there?
致精致简!
Floor 51 Posted 2008-07-16 13:27 ·  中国 江西 南昌 电信
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
It seems that you lack sufficient understanding of relative paths and absolute paths. The \ prefix refers to the root of the current drive. Obviously, because your data file is not on the current drive, it causes an error.
Floor 52 Posted 2008-07-16 14:16 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Yes, I've always been a bit hazy about relative paths... So that's how it is!
致精致简!
Floor 53 Posted 2008-09-25 21:20 ·  中国 辽宁 沈阳 电信云计算机项目(百科合作IDC)
初级用户
Credits 20
Posts 9
Joined 2008-09-10 11:07
17-year member
UID 125296
Gender Male
Status Offline
Floor 54 Posted 2008-09-25 21:45 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 195
Posts 93
Joined 2006-10-28 08:20
19-year member
UID 68626
Gender Male
Status Offline
Actually, awk is very convenient for handling such problems. It's just that many people have preconceived ideas.

BEGIN {RS="。"}
{
gsub (/\n/,"")
print $0"。"}

As usual, I only use code
Floor 55 Posted 2010-01-02 10:45 ·  中国 福建 福州 电信
初级用户
★★
Credits 119
Posts 59
Joined 2008-11-21 14:07
17-year member
UID 131656
Gender Male
Status Offline
I don't know if change supports wildcards
Forum Jump: