•
•
•
•
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
![]() |
•
•
Join Date: Nov 2007
Posts: 122
Reputation:
Rep Power: 1
Solved Threads: 0
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
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
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.
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.
•
•
Join Date: Nov 2007
Posts: 122
Reputation:
Rep Power: 1
Solved Threads: 0
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.
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.
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
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.
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.
•
•
Join Date: Nov 2007
Posts: 122
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
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???
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.
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
----------------------------------------------
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Dot Net programmer wanted. Work from home. (Web Development Job Offers)
- Beginner Question..? (PHP)
- Operating Systems assignment (C++)
Other Threads in the Shell Scripting Forum
- Previous Thread: 101 scripting questions
- Next Thread: check for $1?



Linear Mode