я не могу удалить как одну строку из текстового файла после того, как пользователь вводит название книги и автора (из текстового файла)Bash Script - Как удалить строку/слово из текстового файла?
я попытался этот код
Что я сделал:
function remove_book
{
echo "Title: "
read title
echo "Author: "
read name
echo $title $name < BookDB.txt
echo "Book $title by $name successfully removed!"
sed '/pattern to match/d' ./BookDB.txt
#echo "testing remove"
}
, но потом, это показывает, что это
даже он показывает, как это, они не были фактически удалены из файла ..
Title:
The Hobbit
Author:
J.R.R. Tolkien
The Hobbit J.R.R. Tolkien
Book The Hobbit by J.R.R. Tolkien successfully removed!
Harry Potter and the Deathly Hallows J.K. Rowling
The Maze Runner James Dashner
Life Without Limits Nick Vujicic
The Hobbit J.R.R. Tolkien
Желаемая Выход:
1) Add new book
2) Remove existing book info
3) Update book info and quantity
4) Search for book by title/author
5) Process a book sold
6) Inventory summary report
7) Quit
Please enter your option: 2
Title : Biography of Crocodile Dundee
Author : Crox Swamplund
Error! Book does not exists!
1) Add new book
2) Remove existing book info
3) Update book info and quantity
4) Search for book by title/author
5) Process a book sold
6) Inventory summary report
7) Quit
Please enter your option: 2
Title : C++ for dummies
Author : Edward Scissorhands
Book Title ‘C++ for dummies’ removed successfully!
(книги и собственные имена в Желаемая Output только примеры)
ОТ
Harry Potter and the Deathly Hallows J.K. Rowling
The Maze Runner James Dashner
Life Without Limits Nick Vujicic
The Hobbit J.R.R. Tolkien [remove one line, like this Hobbit book]
К
Harry Potter and the Deathly Hallows J.K. Rowling
The Maze Runner James Dashner
Life Without Limits Nick Vujicic
Как удалить одну строку? после ввода пользователем названия и имени автора? помогите мне, пожалуйста, спасибо! :)
@fedorqui i отредактировал вопрос – Preeyah
Еще один вопрос [BookDB.txt] (https://stackoverflow.com/search?q=%5Bshell%5D+BookDB.txt+is%3Aquestion). –
wow .. no way .. спасибо! @glennjackman: D – Preeyah