shell 给文件每一行都添加指定字符串

 

[admin@localhost file]$ cat file
hello 0
hello 1
hello 2
hello 3
hello 4


[admin@localhost file]$ cat test.sh
#!/bin/bash
while read line 
do
    echo 'buy '$line
done < file >> file_b


[admin@localhost file]$ /bin/bash test.sh


[admin@localhost file]$ ls
file  file_b  test.sh


[admin@localhost file]$ cat file_b
buy hello 0
buy hello 1
buy hello 2
buy hello 3
buy hello 4

 

posted @ 2019-08-23 01:13  anobscureretreat  阅读(1831)  评论(0编辑  收藏  举报