Login
Register
All Activity
Questions
Unanswered
Tags
Users
Ask a Question
About Us
986
Questions
785
Answers
Interview Preparation mode
beta
Funny Facebook Status
Enter your email address
All categories
SQL Server Interview Questions and Answers
(197)
SSIS Interview Questions and Answers
(54)
SSRS Interview Questions and Answers
(9)
SSAS Interview Questions and Answers
(29)
.NET Interview Questions and Answers
(186)
Oracle Interview Questions and Answers
(122)
Java Interview Questions and Answers
(32)
UNIX Interview Questions and Answers
(47)
Networking Interview Questions and Answers
(17)
MySQL Interview Questions and Answers
(30)
HR Interview Questions and Answers
(237)
General Interview Questions and Answers
(9)
Other Interview Questions and Answers
(8)
Job Openings
(3)
Greenplum Database Interview Questions and Answers
(5)
Explain about Redirecting the Output in UNIX
Nice?
Vote!
asked
1 year
ago
in
UNIX Interview Questions and Answers
by
R
(
19,530
points)
unix-interview-question
unix
redirection
1 Answer
Nice?
Vote!
We use the > symbol to redirect the output of a command. For example, to create a file called list1 containing a list of fruit, type
% cat > list1
Then type in the names of some fruit. Press [Return] after each one.
pear
banana
apple
^D (Control D to stop)
What happens is the cat command reads the standard input (the keyboard) and the > redirects the output, which normally goes to the screen, into a file called list1
To read the contents of the file, type
% cat list1
Exercise 3a
Using the above method, create another file called list2 containing the following fruit: orange, plum, mango, grapefruit. Read the contents of list2
The form >> appends standard output to a file. So to add more items to the file list1, type
% cat >> list1
Then type in the names of more fruit
peach
grape
orange
^D (Control D to stop)
To read the contents of the file, type
% cat list1
You should now have two files. One contains six fruit, the other contains four fruit. We will now use the cat command to join (concatenate) list1 and list2 into a new file called biglist. Type
% cat list1 list2 > biglist
What this is doing is reading the contents of list1 and list2 in turn, then outputing the text to the file biglist
To read the contents of the new file, type
% cat biglist
answered
1 year
ago
by
siva
(
10,720
points)
Related questions
Nice?
Vote!
1
answer
Explain about Redirecting the Input in UNIX
asked
1 year
ago
in
UNIX Interview Questions and Answers
by
R
(
19,530
points)
unix-interview-question
unix
redirection
Nice?
Vote!
1
answer
Explain about Redirection in UNIX
asked
1 year
ago
in
UNIX Interview Questions and Answers
by
R
(
19,530
points)
unix-interview-question
unix
redirection
Nice?
Vote!
1
answer
Explain about Searching the contents of a file in UNIX
asked
1 year
ago
in
UNIX Interview Questions and Answers
by
R
(
19,530
points)
unix-interview-question
unix
file
directory
Nice?
Vote!
1
answer
Explain about Displaying the contents of a file on the screen in UNIX
asked
1 year
ago
in
UNIX Interview Questions and Answers
by
R
(
19,530
points)
unix-interview-question
unix
file
directory
Nice?
Vote!
1
answer
Explain about Pipes in UNIX?
asked
1 year
ago
in
UNIX Interview Questions and Answers
by
R
(
19,530
points)
unix-interview-question
unix
pipes