Question form unix newbie


 
Thread Tools Search this Thread
Operating Systems HP-UX Question form unix newbie
# 1  
Old 07-24-2008
Question form unix newbie

hi, just starting to learn about unix in school. got stuck on shell script chapter and need some help i completed task one but the other four is byond me.

Task 1) Write a shell script/program called dow that takes no arguments and displays just the current day of the week in lower case (i.e. mon, tue, etc.). Hint: use date command piped to tr. You will eventually turn in the following:
a) cat dow
b) dow


Task 2)
Create two files as a preliminary to this project. Make the file named names1 contain:

hd
ts
ee
edgar
Make a second file named names2 contain:
mary
ee

hd

edgar
Write a shell script named nameit that outputs a sorted list of unique names from the files. Sample output:

edgar ee hd mary ts

The shell script nameit should contain two Unix commands:

1) First assign the unique lines to a variable named NAMELIST by using the –u option on sort.

Example: to assign the output of the date command to a variable named MYDATE one would typeMYDATE=`date` (those are backquotes around the date).

2) Then display the value of the variable NAMELIST twice within the script using echo, once before the assignment, second after the assignment.
NOTE: Do not create NAMELIST at the system prompt.
You will be turning in the following commands later but you can try them out now:
a) cat names1 names2
b)cat nameit
c) nameit
d)echo $NAMELIST

The last echo commands show that the shell variable NAMELIST no longer exists after the script has been executed.


Task 3) Write a shell script called nbin that uses the if/else statement. Here is the script described in English:

"If there is no bin directory under the current directory, then display the message No local bin here; else display the message bin has XX files" (Note: the XX will be substituted with the acutal number of files in your bin directory)

You will eventually turn in the following:

a) cat nbin
b) nbin


Task 4)
Write a shell script called verbose that takes no arguments. Store separate parts of the output from the date command into shell variables using cut within backquotes. Then use these shell variables to create the following sample output.

Today is Mon day 11 of Nov in year 2001 at 11:49
You will eventually turn in the following.
a) cat verbose
b) verbose

Last edited by wesleywu; 07-24-2008 at 07:33 PM..
# 2  
Old 07-24-2008
GO READ THESE!

One of the rules is dont post your homework here.
# 3  
Old 07-24-2008
ok, thx
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What does this do (newbie question)...

I was looking through some code online and came accross this... ls *.txt | grep text1 | cat file1 – file2 | `echo wc –l` I know what "ls|grep text1" does and I know a word count gets echoed but beyond that I am confused. Please use layman terms as much as possible as I am a newbie. (8 Replies)
Discussion started by: elohssa
8 Replies

2. UNIX for Dummies Questions & Answers

Newbie question

Hey. i am doing a lab work for shcool I am new to using the commands. This question is give to me. I do not no the length of file nor do i know the how many charterers they are in the question. Question below "Assume that you are NOT currently in your home directory. Enter a command to copy... (1 Reply)
Discussion started by: maniac173
1 Replies

3. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

4. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

5. Shell Programming and Scripting

newbie question

hey all, I have repeatedly seen scripts containing the following syntax, grep "hello" $myfile >> $log 2>&1 can anyone explain exactly what "2>&1" mean? THANK YOU (4 Replies)
Discussion started by: mpang_
4 Replies

6. UNIX for Dummies Questions & Answers

Newbie's question about COBOL Installation in Unix

I wanna to install a COBOL on the AIX unix server. Would u like to tell me the disk usage of COBOL installation? Thanks in advance. (2 Replies)
Discussion started by: GCTEII
2 Replies

7. UNIX for Dummies Questions & Answers

Newbie Question

Hi, I have a file, that is delimited by :: and the purpose of this file is none of your business. ;) There are about 65000 lines in this file, and there are lines that I would like to remove. About 45000 of them. Is there some sort of commands that I can run, to remove word(s) from this... (4 Replies)
Discussion started by: th3gh05t
4 Replies

8. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies

9. Programming

Unix/Linux Newbie(ish) Question - IPC/Signals

:) Hello, i have been given the following code to help me learn how to use signals, it won't compile. The problem maybe because this was written for use in Unix and i am trying to compile in Linux. The error i get says that SIGPIPE and SIG_IGN are undeclared. I think that these are defined... (2 Replies)
Discussion started by: theultimatechuf
2 Replies

10. UNIX for Dummies Questions & Answers

Newbie question about unix flavours

Hi, I am newbie to unix. I am been immensily impressed by this forum. I have installed sun solaris in my pc and started learning unix. The question is, If i know one unix flavour (say sun solaris) is that i can claim, i know all the unix and linux flavours. Can i be able to work on other vendor... (3 Replies)
Discussion started by: Balaji
3 Replies
Login or Register to Ask a Question