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 03:43
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Change the first two characters on the first line of a text file from ID to id View 832 Replies 6
Original Poster Posted 2010-06-20 15:40 ·  中国 广东 深圳 电信
初级用户
Credits 21
Posts 21
Joined 2010-06-19 17:50
16-year member
UID 169155
Gender Male
Status Offline
There are many text files. If the first line is ID, it needs to be changed to id, but there are a lot of files.
So I'd like to ask everyone to help think of a solution.
Floor 2 Posted 2010-06-20 15:51 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
About how many files are there?
Floor 3 Posted 2010-06-20 15:52 ·  中国 广东 深圳 电信
初级用户
Credits 21
Posts 21
Joined 2010-06-19 17:50
16-year member
UID 169155
Gender Male
Status Offline
At present I know there are 56 such files, and I know the filenames, but there may be new ones added in the future.
The total number of files is 1000+

It's a set of configuration files sent over by the developers, and every new file that comes in is like this. So I have to change them manually every time, which is very troublesome.

[ Last edited by rockyuan on 2010-6-20 at 15:58 ]
Floor 4 Posted 2010-06-20 18:38 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 5 Posted 2010-06-20 18:49 ·  中国 广东 深圳 电信
初级用户
Credits 21
Posts 21
Joined 2010-06-19 17:50
16-year member
UID 169155
Gender Male
Status Offline
What if they are in different subdirectories?
Floor 6 Posted 2010-06-20 19:26 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Use for /r to traverse them
Floor 7 Posted 2010-06-20 20:10 ·  中国 广东 深圳 电信
初级用户
Credits 21
Posts 21
Joined 2010-06-19 17:50
16-year member
UID 169155
Gender Male
Status Offline
I'm just starting to learn, so I hope someone can give a specific example.
Also, I have two similar operations to ask about:
1, move the original first line of the file to the second line. Write 123 as the content of the first line
2, if the original first line of the file is blank (there is only a newline character, with no characters at all, including spaces), write 123 on this line
Forum Jump: