How can I prepend a string to the beginning of each line in a file?

后端 未结 7 2007
轮回少年
轮回少年 2020-12-08 15:16

I have the following bash code which loops through a text file, line by line .. im trying to prefix the work \'prefix\' to each line but instead am getting this error:

7条回答
  •  囚心锁ツ
    2020-12-08 16:02

    The entire loop can be replaced by a single sed command that operates on the entire file:

    sed -e 's/^/prefix/' $file
    

提交回复
热议问题