#!/bin/bash
library=mylibrary
tmp=mylibrary.tmp
function add_book {
echo Please enter the book title:
read title
existed=`awk -F '$1 == $title' $library | wc -l`
echo $existed
if (( $existed == 0 ))
then
echo Please enter the author:
read author
location=library
updated=$title,$author,$location,`date +%F`
echo $updated >> $library
echo $updated return successfully!
else
echo "Book Exist!"
fi
((我想做的是比较标题,如果标题存在,则回显“书存在”
我希望它将输入与文本文件进行比较))
这是一个示例文本文件:
Title,Author,Location,Date Added
jj,jj,library,2013-11-14
hjj,hj,library,2013-11-14
jhj,hjh,library,2013-11-14