I am trying to create a bash script that will manage a basic inventory system for a friend. Everything he wants to inventory has a barcode, that when scanned, returns a 6 digit number (EX. 000001). I have a piece of code that is supposed to take any input, call it $current, then find $current in data.txt and delete the line. When i am done entering codes, i enter 0 to stop
I couldnt get sed to replace the text in the file directly, so i had it copy to a different file, overwrite the original, then delete the copy. Whenever i run this piece of the file though, it freezes at the sed command and stops running, i can type whatever i want and it wont do anything, including the exit command "0".
read current
until [ $current -eq 0 ]
do
sed '0,/$current/{/$current/d;}' >> data1.txt
cp data1.txt data.txt
rm data1.txt
read current
done