Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with Unix Shell Programming

Posted on 2011-03-20
3
Medium Priority
?
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 2000 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 2000 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

Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

Question has a verified solution.

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

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

705 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