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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM