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

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/11397674.html