各行の先頭に単語を追加するには? [コピー]

各行の先頭に単語を追加するには? [コピー]

ファイル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

おすすめ記事