Mandriva Expert
The place where your Mandriva Linux system finds support

piping question

+/- details
User ansaul
Incident Number 2657
Date 2001/11/11 06:42
Status Incident closed
Paid No

Product 8.1
Architecture x86_32
Scope Administration

Products owned
Community Support question - to convert into a paid question, click here

Lines in bold below have not yet been seen by the customer - those in blue are from the customer

Username : Date : Action : Comments [ close all ]    
 
ansaul : 11/11/01 06:42 AM : Incident created
-   i cant figure out what the differences are between >> and | are. when do i use each? examples?

 
Linegod_7611 : 11/11/01 08:20 AM : Reply received
-   >> and | are two completely different functions. One is used for text
manipulation, and one is used for program output manipulation. Create a file
called 'test.txt' with a line of random text in it for the following examples.

If you wanted to add text to the bottom of a file, you would use >>

# cat test.txt
# echo 'new text'>>test.txt
# cat test.txt

If you wanted to replace the text in a file, you would use >

# cat test.txt
# echo 'new text'>test.txt
# cat test.txt

Piping is used with programs, not text. You 'pipe' one program through the
other.

# rpm -qa
# rpm -qa|grep kernel

In the example above, we piped the output of a search for all the packages in
our system, through a 'grep' (search) for the word kernel.


-----
Note: If this answer resolves your problem, please remember to close this
question.

 
yroagoex : 11/11/01 09:45 AM : Reply received
-   > or >> write in a file

| put the output of the first commmnd to input of the second command

 
ansaul : 11/11/01 08:24 PM : More info provided
-   ok. thanks a lot guys. great examples

 
ansaul : 11/11/01 08:25 PM : Incident closed
-  



This Incident is closed. It can not be edited anymore. You can create a new one by signing up/logging in your Mandriva Expert account.

  Mandriva  |  Contact  |  Legal  |  Privacy  |  Careers