doubt about pipes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting doubt about pipes
# 1  
Old 09-09-2005
doubt about pipes

can we use pipes to redirect the output of any command to grep .....
like i wanted to write this script about checking the online status of a certain user so ...can i send the output of who to grep directly using pipes...
one way was this :
who > temp
grep $uname temp

i was wondering if there is an alternative way to combine these two in to one command
hey i am a total newb so sry if my doubts seem lame
thnx..newaz
# 2  
Old 09-09-2005
you can do like this :
who | grep $uname

Shihab
# 3  
Old 09-09-2005
hey thanks for the prompt reply pal....so this can be generalized for any command tht takes two ommand line arguments like grep??
newaz got another one...is there an equivalent in unix for the split() function in perl
thnx a ton
# 4  
Old 09-09-2005
Most unix commands (where its sensible) read from the standard input stream and write to the standard output stream by default and therefor can be happily strung together with pipes.

There is no direct equivalent of the split function in perl. However it is 'sort of' catered for by the 'for' command. Its probably best to read up on shell scripting rather than have me try to explain how it works. Check the FAQ section.
# 5  
Old 09-10-2005
This is a excellent link originally posted by Vino, I think... you will get whatever you need about scripting in ksh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Pipes in C

Hello all, I am trying to learn more about programming Unix pipes in C. I have created a pipe that does od -bc < myfile | head Now, I am trying to create od -bc < myfile | head | wc Here is my code, and I know I might be off, thats why I am here so I can get some clarification. #include... (1 Reply)
Discussion started by: petrca
1 Replies

2. Shell Programming and Scripting

Doubt about pipes and subprocess

Hi, I am having a trivial doubt. Please see the below pipeline code sequence. command1 | (command 2; commend 3) I am aware that the command that follows pipe will run in the sub shell by the Unix kernel. But how about here? Since these set of commands are grouped under "parantheses", will... (6 Replies)
Discussion started by: royalibrahim
6 Replies

3. UNIX for Dummies Questions & Answers

pipes and shells

Hi How do I direct the output from ls to for example grep a in C. I am not asking for the whole shell implementation. If I write ls|grep myfile in the shell. How is the output sent from ls to the input grep. whit int pipe(pipe); We create the pipe. I and I guess we use dup2(old... (4 Replies)
Discussion started by: isato
4 Replies

4. Shell Programming and Scripting

named pipes

How to have a conversation between 2 processes using named pipes? (5 Replies)
Discussion started by: kanchan_agr
5 Replies

5. Shell Programming and Scripting

Help with pipes in a file

I have to add pipes for particualr number of records in a file. For eg the file has 10 records and i need to add the "|" for records numbers 7 to 10 at particular positons as shown. I need to add pipes in each of these records at positions 9, 11,,21 as like below. Can some body... (7 Replies)
Discussion started by: dsravan
7 Replies

6. UNIX for Advanced & Expert Users

Consolidating Pipes

This is something I've given a lot of thought to and come up with no answer. Say you have a data stream passing from a file, through process A, into process B. Process A only modifies a few bytes of the stream, then prints the rest of the stream unmodified. Is there any way to stream the file... (4 Replies)
Discussion started by: Corona688
4 Replies

7. UNIX for Advanced & Expert Users

FIFO Pipes

Hi...Can anyone please guide me on FIFO Pipes in UNIX.I have lerant things like creating fifo pipes,using them for reads and writes etc.I want to know what is the maximum amount of memory that such a pipe may have? Also can anyone guide me on where to get info on this topic from? (4 Replies)
Discussion started by: tej.buch
4 Replies

8. UNIX for Dummies Questions & Answers

Two types of pipes?

What is the difference between: cd /tmp tar -cf - *.txt |gzip > tmp_txt.tar.gz and cd /tmp mknod pipe p gzip < pipe > /tmp/tmp_txt1.tar.gz & tar -cf pipe *.txt Apart from the fact that we have to create the pipe file manually, is there any difference in the performance of the two?... (5 Replies)
Discussion started by: blowtorch
5 Replies

9. Shell Programming and Scripting

cd using pipes

Hi, Can the cd command be invoked using pipes??? My actual question is slightly different. I am trying to run an executable from different folders and the path of these folders are obtained dynamically from the front end. Is there a way in which i can actually run the executable... (2 Replies)
Discussion started by: Sinbad
2 Replies

10. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies
Login or Register to Ask a Question