p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Beginning Linux Programming, 4th Edition ISBN 978-0-470-14762-7 (http://p2p.wrox.com/book-beginning-linux-programming-4th-edition-isbn-978-0-470-14762-7-375/)
-   -   shell mini cd manager question (http://p2p.wrox.com/book-beginning-linux-programming-4th-edition-isbn-978-0-470-14762-7/94240-shell-mini-cd-manager-question.html)

mashour06 March 8th, 2015 12:03 PM

shell mini cd manager question
chapter 2 mini CD manager. Can any one please explain the next code:
in the function remove_records():

grep -v "^${cdcatnum}," $title_file > $temp_file
mv $temp_file $title_file
grep -v "^${cdcatnum}," $tracks_file > $temp_file
mv $temp_file $tracks_file

any help will be greatly appreciated.
thank you.

geodoomgr June 16th, 2018 04:11 PM

what does the grep do
the code finds lines in the file named title_file
Actually the code finds the lines that do NOT begin with the specified pattern
and saves all these lines in a temporary file. Then the next line renames the temporary file
and gives it the name of the existing file, so it actually substitutes the existing file with a file that does not have the specific lines , so in other words the specific lines were removed.

All times are GMT -4. The time now is 04:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.