p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Linux Programming, 4th Edition ISBN 978-0-470-14762-7 (http://p2p.wrox.com/forumdisplay.php?f=375)
-   -   shell mini cd manager question (http://p2p.wrox.com/showthread.php?t=94240)

mashour06 March 8th, 2015 11:03 AM

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 03: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 07:45 PM.

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