文件1:
Data will be inserted on Thursday
Messages has been sent at 6pm
Office hours is from 9am to 6pm
All the employees are present
输出我想要的:
DMS Data will be inserted on Thursday
DMS Messages has been sent at 6pm
DMS Office hours is from 9am to 6pm
DMS All the employees are present
-或者-
输出我想要的:
Data will be inserted on Thursday DMS
Messages has been sent at 6pm DMS
Office hours is from 9am to 6pm DMS
All the employees are present DMS
我想添加这个词数据管理系统在我文件的每一行中。它可以添加到行首或行尾。
答案1
试试这个,它会对你有帮助。在编辑器中打开文件vi
:
$ vi /file/location
:1,100 s/^/DMS/ --> Enter
1,100
正是您想要从哪一行开始和结束。s
是替换命令,^
表示行开始。
或者您可以使用 GNU sed 在不打开文件的情况下完成此操作:
sed -i 's/^/DMS /' /your/file/location