Wednesday, June 9, 2010

Shell script to Read a line until a keyword is entered

#!/bin/bash
echo "Enter Your sentence. Type exit and press enter to terminate. (Output stored in file named 'samp')";
while [ $!1 ]
do
read a;
echo $a >> testfile
echo `cat testfile` |grep exit > testing
if [ -s testing ]
then
echo "Program exit"
sed -i 's/exit//' testfile
cat testfile > samp
rm testfile
rm testing
exit
fi
done

0 comments:

Post a Comment