Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

Help with Unix Shell Programming

First off, what I need help with is a homework problem and no I am not looking for the answer. I am simply looking for some direction. In 7 weeks we have gone through 13 chapters of UNIX and, being a total N00B to UNIX I am lost. Now we have this project that seems to me impossible given my very limited knowledge of the UNIX OS. What I am looking for is some help structuring the problem into the tasks that I need to do to complete it. For example, "You need to do this first, this second, this third...etc." Please see the attached files.

People tell me I am a geek. Well, I now realize I am not even close. Anyone is any good at UNIX and shell programming has my respect. When this class ends, I don't know if I should start over on the book and go at my own pace or just forget UNIX altogether.  
Programming-Project-1.txt
datecalc
download-TOC-2-
toc-download.sh
0
BoxunloX
Asked:
BoxunloX
  • 3
2 Solutions
 
farzanjCommented:
Hi,
First, take a deep breath and say loud, "Scripting is fun!".

How to Start:
Open a shell script.  I want to give you exercises that would help you understand pieces involved.

Need to Understand:
Shell script is the use of very tiny operations tied together to get a much better functionality.

How to go about it:
Play with little lines of code right on the shell.  If you are good with one liners, you can put them together and get your solution done.

Strategy:
Play with the shell.  Have fun
0
 
farzanjCommented:
Exercises

What do the following commands do?

echo *
Make a directory test
     % mkdir test
     % cd test || echo "cannot change directory"
Now press up arrow key, which should bring the command once again and run the same command again.
Did you notice any difference?
Now issue this command
% cd test || echo "cannot change directory" 2> /dev/null
Did you notice any difference?  If not, use up/down arrow keys and run them over and over again.
This is what I meant by "play and have fun"

Run this command
% for i in *
>  do
>  echo $i
>  done

What did you see
Try this:
% for i in *
>  do
> echo file $i
> done

Now try this:
% myval="good"
% case $myval in
> good) echo "You typed good";;
> bad)  echo "You typed bad";;
> esac

What do you see?

Now do this:
% myval="bad"
Use up arrow to get the above case statement and press enter.
What do you see now?
0
 
farzanjCommented:
I just told you how to play with the shell.  You need to play some more.  So now, you can start playing with your program toc-download.sh

Try each command separately and try to understand what each command does.  If you cannot understand anything, you should open separate questions for each part that you don't understand.  This way it will be learning not cheating.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now