Book name:author:price:Qty:Qty Sold
==================================
harry potter:james:12.99:197:101
===============================
この場合は 197 の値である QTY を更新したいのですが、シェル プログラミングの学習を始めたばかりなので、自分のプログラムで値を更新できないようです。助けてください。ありがとう
function update_qty_available
{
grep -c "$title:$author" BookDB.txt > /dev/null # Look for a line with matching values
if [ $? == 0 ];
then # If found then offer to change Qty
echo "Update Qty to what?"
read newQty
sed -i "s/\($title:$author\):[^:]:[^:]*:/\1:$newQty/" BookDB.txt
echo "Book's Qty has been updated successfully!"
fi