return 0 ;; 1) ;; 2) echo "Sorry, not unique." echo "Found the following" cat $temp_file get_return return 0 esac IFS=", " read cdcatnum cdtitle cdtype cdac < $temp_file IFS=" " if [ -z "$cdcatnum" ]; then echo "Sorry, could not extract catalog field from $temp_file" get_return return 0 fi echo echo Catalog number: $cdcatnum echo Title: $cdtitle echo Type: $cdtype echo Artist/Composer: $cdac echo get_return if [ "$asklist" = "y" ]; then echo -e "View tracks for this CD? \c" read x if [ "$x" = "y" ]; then echo list_tracks echo fi fi return 1}8. Функция
update_cdgrep^$cdcatnum", "$cdcatnum{}{}get_confirmupdate_cd() { if [ -z "$cdcatnum" ]; then echo "You must select a CD first" find_cd n fi if [ -n "$cdcatnum" ]; then echo "Current tracks are :-" list_tracks echo echo "This will re-enter the tracks for $cdtitle" get_confirm && { grep -v "^${cdcatnum}, " $tracks_file > $temp_file mv $temp_file $tracks_file echo add_record_tracks } fi return}9. Функция
count_cdscount_cds() { set $(wc -l $title_file) num_titles=$1 set $(wc -l $tracks_file) num_tracks=$1 echo found $num_titles CDs, with a total of $num_tracks tracks get_return return}10. Функция
remove_recordsgrep -vЕсли вы попытаетесь применить команду:
grep -v "^$cdcatnum" > $title_fileфайл
$title_file>grepremove_records() { if [ -z "$cdcatnum" ]; then echo You must select a CD first find_cd n fi if [ -n "$cdcatnum" ]; then echo "You are about to delete $cdtitle" get_confirm && { grep -v "^${cdcatnum}, " $title_file > $temp_file mv $temp_file $title_file grep -v "^${cdcatnum}, " $tracks_file > $temp_file mv $temp_file $tracks_file cdcatnum="" echo Entry removed } get_return fi return}11. Функция
list_tracksgrepcutmore