tumichaelf
IS-IT--Management
I am writing script to read through a bunch of data, the script is below
essentially, it is looking through the hgrc files and if it does not find the [hooks] text, it is echoing the path and filename to output.out.
What I need is a script to that search and add [hooks] as the last line of the file (there would be an empty line above it).
Any help is appreciated.
Code:
#!/bin/bash
rm -f output.out
files=`find -name hgrc`
for file in $files ; do
srch=`grep -iq "[hooks]" $file`
if [ "$srch" == "0" ] ; then
echo $file >> output.out
fi
done
essentially, it is looking through the hgrc files and if it does not find the [hooks] text, it is echoing the path and filename to output.out.
What I need is a script to that search and add [hooks] as the last line of the file (there would be an empty line above it).
Any help is appreciated.