Solved

Help with Unix Shell Programming

Posted on 2011-03-20
3
317 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

19 Experts available now in Live!

Get 1:1 Help Now