i wrote script for if file exists script do file edit problem with the script get stuck not existing as for exit i mentioned exit 0 , and how to give the exception for script it should add
./script -- add hi
./script --add "hi how are you"
now below script with case it is working for ./script -- add hi
how to add exception it should not take any string example
./script --add "hi how are you"
and how to send my arguments should accept and add the string to file ./script --add "hi how are you"
function fileread() {
filename=$1
echo $filename
if [ $2 == add ]
then
echo $3 >> $filename
echo "add opeartion completed"
# cat $filename
shift
else
echo " add not done"
fi
if [ ! -z "${4/ //}" ]
then
echo "adding"
fileread $fileName $3 $4
else
echo "arguments or values not proper"
helpFunc --arg2;
exit 1
fi
exit 0