HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   Phone Shell Script ? (http://www.howtoforge.com/forums/showthread.php?t=20115)

anything 4th February 2008 17:02

Phone Shell Script ?
 
guys I truly need the solution of this, with some explanation !

script (called phone) that creates a simple telephone list (create an empty file called “phonlist” in home directory) . Each line in this file consist of two fields name and the phone number, the script should do the following:
When user types the command : “phone new <name> <number>” this will add new record (name,number) to the list.
When user type command: “phone <name>” then the script should search in the file “phonelist” and gets the phone number and display the result.

and what does these commands do:

[[ -z $user ]]

--

grep

--
-eq 1 0
--

[[ `grep -c $user` -eq 1 ]]

--

thanks

falko 5th February 2008 18:25

I don't have a solution ready for you, but you can read through this guide: http://tldp.org/LDP/abs/html/

Afterwards you'll be a bash scripting genius. :)

anything 5th February 2008 20:49

thank you, but I really need a solution for that script, I must read and learn to do my tasks but I am a bignner on it and dont have time, so please forgive me

topdog 5th February 2008 21:25

Quote:

Originally Posted by anything
and what does these commands do:

[[ -z $user ]]

--

grep

--
-eq 1 0
--

[[ `grep -c $user` -eq 1 ]]

--

thanks

The first tests if $user veriable is empty,

The second is invalid

The third tests if the number of characters in $user variable has more one character.

And finally i will write you a quick script when i have some time on my hands

sjau 6th February 2008 23:33

http://www.linuxcommand.org --> great site to start bash scripting...


All times are GMT +2. The time now is 01:59.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.