In this post, i wanted to write a shell script to search a parameter/Word in a file and append the value if the word/parameter is not there in the file.
#!/bin/bash
grep -i "Pasupula" /tmp/Sravan/info.txt
if [ $? == 0 ]
then
echo " Already search content was there in the file"
else
echo -e " Sravanakumar_Pasupula from bangalore" >> /tmp/Sravan/info.txt
fi
here, info.txt is a file, under which i wanted to search a word "Pasupula", if the word is exists in the file nothing to append, if the word is not there in the file then execute the command by appending the Sravanakumar_Pasupula from Bangalore.
No comments:
Post a Comment