Learning - UNIX Programming Questions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Learning - UNIX Programming Questions
# 1  
Old 03-07-2014
Learning - UNIX Programming Questions

Type in commands that do the following.

Part 1

Send the output to a textfile using the "script" command.

Attach the "script" file with your output. Don't worry about any mistakes while you are typing - you don't need to do it over and you don't need to clean up your script file.

1) create a directory
2) change the directory permissions to rwxr-wr-w (if your system won't allow you to, don't worry about it)
3) go into the directory
4) touch a file
5) create a file called testfile and enter in a bunch of text, save and exit the file
6) grep a directory for some text - it doesn't matter what text it is
7) find the /etc/passwd file
8) create another directory, add files in the directory, and remove the directory
9) go to another directory somewhere and type in the command that displays your current directory
10) type in the command to display all of your filesystems

Part 2

Use the bash shell for the following:


#1 Create a file called testfile.

#2 Make the file executable (what command did you use)?

#3 Add the following lines to the testfile


echo Hello $LOGNAME!
echo The hour that this script is running is `date +%H`
echo "This system name is `uname -n`"
echo Display the calendar for this month:
cal 11 2009
echo The processes that I am running are:
ps -ef | grep "^$LOGNAME"
echo "This is the end of the shell script!"



What is the output of this script?

Run in debug mode:

sh -x ./testfile

What is this output?


#4 We will now test reading in standard input into a variable that can be used.

ex:

echo -n "What is your name? "
read name

echo Greetings to you, $name.

Write a small program that asks the user for their favorite color and outputs the
color back. What does the program say?

#5 Type in the following to set your terminal type to vt100.

$ export TERM=vt100

$ echo $TERM

What is the output?

#6 Type in the following to add /local/bin to your current search path.

$ export PATH=/local/bin:$PATH

$ echo $PATH

What is the output?


#7 Type in this command to re-execute the .profile script? (.profile for ksh .bash_profile for bash)

$ ./.profile or .bash_profile

$ echo $SHELL

What is the output?

Type in the “set” command and the “ env”, capture the ouput and paste as your answer.

#8
What are the following set to?
HZ
PATH

LOGNAME

SHELL

HOME
TERM
PWD
TZ





#9 What command did you use to find out?

#10
Type in the following command:

echo less than b r divided by greater than less than b r divided by greater than N o w r u n p s minus e f vertical line g r e p w h a t e v e r t h e o u t p u t w a s minus w h a t i s t h e s i g n i f i c a n c e o f less than b r divided by greater than t h e e c h o command?





Part 3



Regular Expressions

Write a regular expression that reads the following:

a.summer

2. Write a regular expression that reads the following:

home/asummer/files

3. Find the word MaryBeth if it is at the beginning of a line: What is the expression?



Find the word MaryBeth if it at the end of a line: What is the expression?

5. Match the vowels (both upper case and lower case): What is the expression?



Match all numeric characters: What is the expression?

7. Match all characters that are not alphabetic: What is the expression?



Match zero or more consecutive C's: What is the expression?



Match one or more consecutive E's: What is the expression?



Redirect output



Create a file called output.file from the output of the calendar command: What is the command?



Add the output of the date command to the file that you created from question #10: What is the command?



email this file to Sandra@neu.edu - what is the command?



translate all upper-case characters in output.file to lower-case and write the results to standard output: What is the command?



What does the following command do?



who | tee outfile.file | grep yourusername

replace yourusername with your username then

cat outfile.file

and copy the output to your homework



*********************************************************************

Assume the following files exist in the current directory:



ls -a



.

..

.dalog

.molog

a

ab

abc

dabkup1

dabkup2

dabkup3

dabkup4

dabkup5

mobkup1

mobkup2







Under this directory is a subdirectory called bin that has the following files:



smail.Z

calc.Z

testsh.Z



Under the subdirectory bin is a subdirectory called foodir that has the following file:



foo.Z



What is the output for the following commands:



ls d*



ls *1 (as in the number 1)



ls *ab



Without changing to the bin subdirectory, what is the output of the following command?



ls */* .Z



What is the output of the following command?



ls */*/*.Z



What is the output of the following command?



echo .*



What is the output of the following command?



echo ??



What is the output of the following command?



echo ???*



What is that command doing?



What is the output of the following command?



ls [am]*



What is the output of the following command?



echo [dm]*[1-5]



What is this command doing?



What is the output of the following command?



ls [!d]



What is the “!” doing?



What does the following command do?



rm *.[!em]



27. What does the following command do?




find / -name file -print 2> errors.txt



1) Given the following assignments:

$ x=*
$ y=?
$ now=`date`
$ greater='>'

$ echo $SHELL
/bin/bash
$ export x=*
$ export y=?
$ export now=`date`
$ export greater='>'


and these files in your current directory:


$ mkdir one
$ mkdir two
$ mkdir a
$ mkdir bb
$ mkdir giraffe

What will the output be for the following commands?

echo *

echo **** error *****

echo $x

echo $y

echo "$y"

echo '$y'

echo _$now_

echo hello $now out

echo "\""

echo 'Is 6 * 4 > 20 ?'

echo 6*4

echo 6 * 4

echo What is your name?

echo \*\*\*

echo \$now

echo $\$now

echo "\\"

echo '\\'

echo \\

echo "What's the word?"


When you create a script, make certain that you set the permissions to executable. rwx or r-x
2)

Write a short program that prompts for your favorite color. Using the case statement give 4 acceptable answers, display different responses depending on the answer that is given. Also, give an option to exit from the script.

Include a printout of the script.

3)
Write a short program that
a: prompts for a filename to search for
b: searches the current directory for the filename
c: if it finds the filename the output reports that it found the filename with
the complete path and filename
d: if it does not find the filename the output reports that to the display
# 2  
Old 03-07-2014
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

2. Programming

What Programming language should I start learning first?

I want to create a computer program that will translate from English to Spanish and vice versa. So someone could type in a word, phrase, or paragraph and translate from one language to another. What programming language would I use to write up the code and then implement this program? I want to... (8 Replies)
Discussion started by: Anna Hussie
8 Replies

3. UNIX for Dummies Questions & Answers

Learning UNIX

Hi Everyone, I know nothing about Solaris / Linux / AIX but I know they are all part of Unix. I have been using Windows the last 15years and I have been a LAN admin, I am now working in IT Operations and we use some solaris commands but not much plus its from following a document so we can't... (1 Reply)
Discussion started by: maxie
1 Replies

4. UNIX for Dummies Questions & Answers

Carreer:Networking Programming in Unix (C programming Language)

Hello, I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies

5. UNIX for Dummies Questions & Answers

learning unix

Hi, i have started to learn unix (on and off for the past few months) and am wishing to move into that area in the administration field of it. I have been working in the help desk area (desktop support - windows based) for about 2.5 years and moved into a team leading role for 1 year in which i... (1 Reply)
Discussion started by: donnieDarko
1 Replies

6. UNIX for Dummies Questions & Answers

Learning Unix

Hi all, and thanks for viewing this thread. I have never used the terminal (UNIX) before, not until I read an introductory book about it: Unix for Mac OS X Tiger. Now I've become intrigued, and I want to uncover more of the mysteries of Unix. I've searched and searched, but there are many books... (5 Replies)
Discussion started by: Hin
5 Replies

7. UNIX for Dummies Questions & Answers

Learning UNIX

Hi guys! Am new to this forum so would like to say hello to all. Was wondering, what the best way to learn UNIX was? Theoretically or Practically? Cheers (2 Replies)
Discussion started by: bibah11
2 Replies

8. UNIX for Dummies Questions & Answers

where to obtain UNIX and learning on a UNIX variant?

Hi. I've just started to get into UNIX. Researched on the Net, found out that most of the UNIX variants are not offered online. 1. Any of you guys know where I could obtain them on the Net? or anywhere at all? 2. Does learning a UNIX variant enough to cover an understanding of other UNIX... (6 Replies)
Discussion started by: ninelives1980
6 Replies

9. UNIX for Advanced & Expert Users

Learning Unix

Hello one and all I am a Prof in a University in France and have been handed the "Unix" course and would like to know if anyone has a ready made course to propose to me for beginners, my students are in t heir first year and a few are ok with Unix, however i would like to find a detailed "lesson... (1 Reply)
Discussion started by: garydavies
1 Replies

10. Post Here to Contact Site Administrators and Moderators

Where does programming questions go?

I am a basic programmer from way back. I moved on to visual basic when the time came but have always wanted to learn C. Now that I am on linux, I am ready for the push. Where would be the appropiate fourm to discuss programming? Thanks, Eric (wanting to learn) (2 Replies)
Discussion started by: wizkid
2 Replies
Login or Register to Ask a Question