|
INTERVIEW QUESTIONS
OPERATING SYSTEMS
UNIX PROGRAMMING
DETAILS
Question: How do I redirect stdout and stderr separately in csh?
Answer: In csh, you can redirect stdout with ">", or stdout and stderr together with ">&" but there is no direct way to redirect stderr only. The best you can do is
( command >stdout_file ) >&stderr_file
which runs "command" in a subshell; stdout is redirected inside the subshell to stdout_file, and both stdout and stderr from the subshell are redirected to stderr_file, but by this point stdout has already been redirected so only stderr actually winds up in stderr_file. If what you want is to avoid redirecting stdout at all, let sh do it for you.
sh -c 'command 2>stderr_file'
|
|
|
Category |
Unix Programming Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 7940 users |
Added on |
8/26/2014 |
Views |
69232 |
Rate it! |
|
|
Question:
How do I redirect stdout and stderr separately in csh?
Answer:
In csh, you can redirect stdout with ">", or stdout and stderr together with ">&" but there is no direct way to redirect stderr only. The best you can do is
( command >stdout_file ) >&stderr_file
which runs "command" in a subshell; stdout is redirected inside the subshell to stdout_file, and both stdout and stderr from the subshell are redirected to stderr_file, but by this point stdout has already been redirected so only stderr actually winds up in stderr_file. If what you want is to avoid redirecting stdout at all, let sh do it for you.
sh -c 'command 2>stderr_file' Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do I {set an environment variable, change directory} inside a program or shell script and have that change affect my current shell?
|
View Answer
|
|
Why do I get [some strange error message] when I "rsh host command" ?
|
View Answer
|
|
How do I rename "*.foo" to "*.bar", or change file names to lowercase?
|
View Answer
|
|
How do I get the current directory into my prompt?
|
View Answer
|
|
How do I get a recursive directory listing?
|
View Answer
|
|
How do I remove a file with funny characters in the filename ?
|
View Answer
|
|
How do I remove a file whose name begins with a "-" ?
|
View Answer
|
|
What happened to the pronunciation list that used to be part of this document?
|
View Answer
|
|
What are some useful Unix or C books?
|
View Answer
|
|
How does the gateway between "comp.unix.questions" and the "info-unix" mailing list work?
|
View Answer
|
|
What does {some strange unix command name} stand for?
|
View Answer
|
|
When someone refers to 'rn(1)' or 'ctime(3)', what does the number in parentheses mean?
|
View Answer
|
|
Who helped you put this list together?
|
View Answer
|
|
Describe about awk and sed?
|
View Answer
|
|
Explain the basic forms of each loop?
|
View Answer
|
|
Explain about the case statement.
|
View Answer
|
|
What is a FIFO?
|
View Answer
|
|
Brief about the directory representation in UNIX
|
View Answer
|
|
What is 'inode'?
|
View Answer
|
|
How are devices represented in UNIX?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Unix Programming Interview Questions & Answers - Exam Mode /
Learning Mode
|