Solved

Help with Unix Shell Programming

Posted on 2011-03-20
3
319 Views
Last Modified: 2012-05-11
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
Comment
Question by:BoxunloX
  • 3
3 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 35175235
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
 
LVL 31

Expert Comment

by:farzanj
ID: 35175347
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
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 500 total points
ID: 35175360
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now