LINUX programming

Moderators: ITA
Number of threads: 1347
Number of posts: 2935

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
linux help Posted by Rulis88 on 10 Feb 2013 at 9:22 AM
Hey, I'm kinda new here and I'm here to ask you for a favor. So I've got a homework on linux programming and I'll need to explain this whole script to my lecturer in tomorrow. Can any of you please explain what does each segment of this script does? Thanks in advance.

#!/bin/bash

echo '1. New entry (Name, Surname, phone number, e-mail):'
echo '2. Entry search'
echo '3. List all entries'
echo '4. Delete an entry'
echo '5. Edit an entry'
echo '6. Quit'

choice=0
while [ $choice -ne 6 ]
do

read choice

case $choice in

1)
echo 'Ener Name, surname, phone number and e-mail, separated by spaces:'
read id
echo $id >> info.txt
;;

2)
echo 'Enter id data to search for:'
read search
grep -n $search info.txt
;;

3)
echo 'Full entry-list:'
cat -n info.txt
;;

4)
echo 'Specify an entry # for removal:'
cat -n info.txt
read del
sed $del'd' info.txt>temp
mv temp info.txt
cat -n info.txt
;;

5)
echo 'Specify an entry # for editing:'
cat -n info.txt
read edit
echo 'Enter new data:'
read id
sed -i "${edit} s/.*/${id}/" info.txt
;;

6)
echo 'bye'
;;

*)
echo 'Wrong selection'
;;
esac
done



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.