add_description.sh #!/bin/bash if ! grep -q "^#!" $1; then sed -i '1i #!/bin/bash' $1 sed -i '2i Description: ' $1 fi 验证: [root@logstash ~]# cat hive.output avg: 120003 Max: 120008 [root@logstash ~]# sh add_description.sh hive.output [root@logstash ~]# cat hive.output #!/bin/bash Description: avg: 120003 Max: 120008 [root@logstash ~]# 原创作者: ztj1216 转载于: https://blog.51cto.com/ztj1216/11888591