Developer's Closet A place where I can put my PHP, SQL, Perl, JavaScript, and VBScript code.

26Sep/170
Search for string and append string to file

A very useful string search and append that I find myself rewriting over and over. So I've decided to write a post and capture the script:

if grep -q sensu-client "/etc/rc.local"; then
echo "exists";
else
echo "does not exist"
sudo sed -i '/exit 0$/i sudo service sensu-client restart' /etc/rc.local;
fi

 

Filed under: Bash, Linux, Ubuntu Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.