嗨,我是新的shell編程,我希望你能引導我一路謝謝。按書名/作者搜索的書
嗨,我需要一個函數來從.txt文件中搜索要麼書名或作者和回聲出以下
Title:*Enter*
Author:Scissorhands
找到3個記錄: C++傻瓜,約翰剪刀手,$ 15.01,10,5 Java的傻瓜,瑪麗剪刀手,$ 16.02,20,15 VB.NET傻瓜,剪刀手愛德華,$ 17.03 30,25
如
Found 3 records :
C++ for dummies, John Scissorhands, $15.01, 10, 5
Java for dummies, Mary Scissorhands, $16.02, 20, 15
VB.NET for dummies, Edward Scissorhands, $17.03, 30, 25
我的文件格式是如下
書名:作者:價格:數量:數量銷售
哈利波特:詹姆斯:12.99:197:101
function Search_book
{
FILE="/home/student/Downloads/BookDB.txt"
echo found 1 records : $FILE contents
cat FILE
}
沒有@triplee告訴你在你的[上一個](http://stackoverflow.com/questions/17849131/how-to-use-sed-to-find-the-corresponding-place-in- a-text-file-and-update-it-shel)後,JKRowling寫了哈利波特的書。 – devnull
這只是一個例子哈哈,我怎麼能以這種格式顯示這本書?星球大戰VI - 絕地,阿比旺基諾比的回報,$ 15.98,20,15,如果我的.txt格式是哈利波特:詹姆斯:12.99:197:101 –