User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 425,817 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,076 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1087 | Replies: 6 | Solved
Reply
Join Date: Nov 2007
Posts: 122
Reputation: k2k is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
k2k k2k is offline Offline
Junior Poster

unix little quiz

  #1  
Jun 29th, 2008
hi, i had a few unix questions that I am not sure about the answers. if anybody can give a try... that would be great.

1. In sed, when you do pattern matching, the largest pattern is always matched first, left to right. True or False

2. The command tr 'a-z' 'A-Z' | tr 'A-Z' 'a-z'
after the command is run, case of the input stream will be swapped. True or False
# i tried, the output is a bit weird....

3. File substitution always happens on variable assignment. True or False

4. In the command
echo "hello world" >&2 2>outfile
both standard output and standard error are sent to outfile True or False

5. Which statement best describes when filename generation (expansion) can occur?
a. inside of single quote
b. ......... double quote
c. ........... backquote
d. B & C
e. A and B and C

6. The command
rm "-foobar"
will correctly delete a file named, -foobar
True or False

7. The program 'ls' is a UNIX filter
True or False
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,635
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 22
Solved Threads: 415
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: unix little quiz

  #2  
Jun 29th, 2008
Smells like homework - where's your attempt at answers?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: Apr 2008
Posts: 39
Reputation: omrsafetyo is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 8
omrsafetyo omrsafetyo is offline Offline
Light Poster

Re: unix little quiz

  #3  
Jun 29th, 2008
Yeah... where are you taking this "quiz"?
You seem to have a lot of questions, and it is certainly hard to tell if its because you are trying to learn or cheat. If its just an online quiz - can you provide a link? I'd be interested in taking a try myself.
Reply With Quote  
Join Date: Nov 2007
Posts: 122
Reputation: k2k is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
k2k k2k is offline Offline
Junior Poster

Re: unix little quiz

  #4  
Jun 30th, 2008
this is homework and i probably shoulda mention. However, it is all open book open notes and free to discuss with classmates or anybody else. There are totally 42 questions and I am not sure about these 6 or 7.

I had many questions posted but most of them weren't asking anyone to do anything bigger than one line of script. It is just I had encountered many new situations being new to shell scripting. And I solved my own problem and posted it for whoever needs the solution too... so...

i love this site becoz most post got answered... not all answers are the right answer but it always gave me hints and of coz sometimes just the exact answer.

if anybody doesn't feel ok to answer some question looks like hw.. it is fine... and i didn't know those questions shouldn't be posted.
Reply With Quote  
Join Date: Dec 2005
Posts: 3,635
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 22
Solved Threads: 415
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: unix little quiz

  #5  
Jun 30th, 2008
http://www.daniweb.com/forums/announcement113-2.html
Posting them is fine, so long as you show some effort.

You almost made it with
"# i tried, the output is a bit weird...."
but it would have been better if you'd actually copied and pasted what you tried.

Question 1 is answered in the manual
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: Nov 2007
Posts: 122
Reputation: k2k is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
k2k k2k is offline Offline
Junior Poster

Re: unix little quiz

  #6  
Jun 30th, 2008
Originally Posted by Salem View Post
http://www.daniweb.com/forums/announcement113-2.html
Posting them is fine, so long as you show some effort.

You almost made it with
"# i tried, the output is a bit weird...."
but it would have been better if you'd actually copied and pasted what you tried.

Question 1 is answered in the manual


Question 1 I actually found it the answer true somewhere on a unix tutorial website.... however, i don't get what it meant by the largest pattern; to match with . or * , * is probably the larger pattern but why matched first.... ==' i don't see it.

Question 2 i got below
$ a="main street NEW YORK USA"
$ echo $a | tr 'a-z' 'A-Z' | tr 'A-Z' 'a-z'
main street NEW YORK USa

my interpretation is it should translate $a 's lower case to upper case .. and then it should be all upper case... and translate to lower case... however, the result remain the same but USa instead of USA... isn't it weird???
Reply With Quote  
Join Date: Feb 2006
Posts: 1,460
Reputation: masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice 
Rep Power: 9
Solved Threads: 130
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: unix little quiz

  #7  
Jun 30th, 2008
Question 1. What if the same pattern also fits inside the "largest" pattern? i.e

pattern: A.*B
String: ABCDEFBGHIJK

Is AB matched, or is ABCDEFB matched?

Question 2:

What is th difference between 'A-Z' and '[A-Z]'? (Although there are other things in tr that should be used for this.)

Question 3:

Are you sure you copied it right as:
File substitution always happens on variable assignment.
doesn't seem right to me.

Question 4:

Knowing that handle>&handle redirects the first handle to whatever "stream" the second handle currently points to, and handle>outputStream redirects the listed handle to a newly created output stream, what do you think the answer is? Hint, the keyword in that question is marked.

Question 5:

Simply try it.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 4:09 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC