bash,scripting


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions bash,scripting
# 1  
Old 12-12-2009
Error bash,scripting

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

i have to do this but i am confused,

Create a file containing the bash functions which perform the following tasks. Clearly label each function. Print out and turn in this file.

1.Write a function which displays the current date, time, username, and current directory.

2.Write a function which displays all of its parameters (no matter how many).

3.Write a function called reverse which will display the reverse of an integer. The function will take exactly 1 argument and display the result. That is, typing
reverse 12345
results in the output
12345 reversed is 54321

4.Write a function called comp which performs integer arithmetic (addition, subtraction, multiplication, division, and modulus). The function will take exactly 3 arguments - two operands and an operation - and display the results. That is, typing
comp 5 + 3
results in the output
5 + 3 = 8
Your function should verify that there are exactly 3 parameters.

5.Write a function called summer which will add up a list of integers (length unknown). That is, typing
summer 1 2 3 4 5
results in the output
15



2. Relevant commands, code, scripts, algorithms:

Hint: First write the function to add two integers. Then create a recursive function which shifts the parameters, adding the new first parameter to the sum.


3. The attempts at a solution (include all code and scripts):



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
UT Panamerican, EDINBURG,TX,USA, Egle, 2344


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 12-13-2009
Please review the guidelines on posting homework.

Last edited by Scott; 01-13-2010 at 08:43 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Bash Scripting

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Try running 'phone4 xyz' and see what happens. Modify your program so that if no matching name is found, an... (1 Reply)
Discussion started by: OmgHaxor
1 Replies

2. Shell Programming and Scripting

bash scripting help

Hi Guys i have a <script?> that spits out the location of each printer using snpget here is the code for i in `sed -n '/Start Printer/,/End Printer/p' /hosts/blah/etc/dhcp/hosts.conf | awk '!/^#/ {print $2}' | egrep -v \... (2 Replies)
Discussion started by: ab52
2 Replies

3. Shell Programming and Scripting

Bash scripting

Try to imagine a flag: nnnnx nnnxx nnxxx nxxxx now imagine how it will output: 4 times the "n"and 1 times "x" 3 times "n"and" 2 times" x " .. etc. .. rhombus is the same only instead of "n" is there gap "and " x "is a few times to form the correct shape Can you help... (3 Replies)
Discussion started by: krcek12
3 Replies

4. Shell Programming and Scripting

bash scripting

Hello everyone!!!! I am new to this forum ...I have a problem. And I thought that you are expert :) so you can help me with that... I have a text file with maaany lines. Every line begins with something like that: <http aksjfskcuhrf kushkfsnus> <http sxnfrksehfsd gsdg r> I don't know if every... (16 Replies)
Discussion started by: mary_elen
16 Replies

5. Shell Programming and Scripting

bash scripting help

have this code but when i run it i get this error ./pulse: line 2: and here is the code #!/bin/bash if ; then pulseaudio -k; fi what am i doing wrong thanks Adam (5 Replies)
Discussion started by: ab52
5 Replies

6. Shell Programming and Scripting

please help with Bash Scripting????

Hi, can anyone help me with my scrip please. I wanted do following tasks: 1. List all the directory 2. A STDIN to ask user to enter a directory name from listed directories 3. command to check if the directory exists( or a command to validate if the user entered a valid directory name) ... (2 Replies)
Discussion started by: eminjan
2 Replies

7. Shell Programming and Scripting

bash scripting help!!

Hi, can anyone help me with my scrip please. I wanted do following tasks: 1. List all the directory 2. A STDIN to ask user to enter a directory name from listed directories 3. command to check if the directory exists( or a command to validate if the user entered a valid directory name)... (3 Replies)
Discussion started by: eminjan
3 Replies

8. UNIX for Dummies Questions & Answers

Should I do a bash scripting course?!

Hello, I'm confused (oh, yes). I'm running Linux at work. When I type 'echo $SHELL' I am told that I'm running tcsh. In /bin I note that both tcsh and bash are listed. Question 1: Can I swap to run bash rather than tcsh and, if so, how will this affect my system? Is there any advantage to... (6 Replies)
Discussion started by: macpete
6 Replies

9. Shell Programming and Scripting

Bash Scripting

Hello there peeps: There is a little piece of bash shell scripting problem i have, which i was hoping you could help me with. #!/bin/bash stored_word() { case $(( $$ % 8 )) in 0 ) echo "energy";; 1 ) echo "touch";; 2 ) echo "climbing";; 3 ) echo... (3 Replies)
Discussion started by: keyvan
3 Replies
Login or Register to Ask a Question